T
Tim Hunter
I'm trying to code a method that has two result values. The values are
very different objects: an Image (a large and complicated object) and a
plain ol' Ruby Float. I'm not sure what the best way to handle this is. I
could return them an Array with 2 elements, but that feels too
lightweight. I could return a Hash with 2 members. I could define a new
class with two attributes, but that feels too heavyweight. I even thought
of having the method yield to a block, passing the two results as
arguments to the block, but that just seems bizarre.
So I'm soliciting advice. How has this been solved before?
very different objects: an Image (a large and complicated object) and a
plain ol' Ruby Float. I'm not sure what the best way to handle this is. I
could return them an Array with 2 elements, but that feels too
lightweight. I could return a Hash with 2 members. I could define a new
class with two attributes, but that feels too heavyweight. I even thought
of having the method yield to a block, passing the two results as
arguments to the block, but that just seems bizarre.
So I'm soliciting advice. How has this been solved before?