I have a calculate(data) method that returns two values. One is the class ( Float ), and the other is the details (Hash ). Comparing the following two options, is there a preferred way?
def calculate(data) ... [grade, details] end grade, details = calculate(data)
vs.
def calculate(data) ... Result.new(grade, details) end result = calculate(data) grade = result.grade details = result.details
What is more idiomatic in Ruby?
source share