Re:Every language fixes something - a DiGraph - just for fun
by zwp on Thursday July 28, 2011 @02:13PM
(#2818141)
> way to return a list of four arguments from a method
p, q, r, s = * method_that_returns_array_of_4_things
* aka "splat operator"
Re:Every language fixes something - a DiGraph - just for fun
by kragen on Thursday July 28, 2011 @02:27PM
(#2818208)
That's great, thanks! And that works for method calls too. So now I can replace set_color_from @cells[x][y] with fill *color_from(@cells[x][y]), reducing the number of side-effecting methods by one, and now I'm calling every Processing function in at most one place.
It does call fill from four call sites, but that was because there's no reasonable way to return a list of four arguments from a method in Ruby, as far as I can tell.