S
Simon Strandgaard
It would be awesome, if #inject could do splitting when arity > 2.
For instance converting an array of pairs into a hash (arity==3):
x=[["name", "john"], ["age", 20]]
p x.inject({}){|h,k,v|h[k]=v;h}
#=> {"name"=>"john", "age"=>20}
Also #partition cannot deal with arity > 2..
All other iterator methods seems to deal ok with arity>2.
Have I forgotten any iterator methods ?
I have submitted the RCR here:
http://www.rubygarden.org/article.php?sid=333
Any thoughts ?
For instance converting an array of pairs into a hash (arity==3):
x=[["name", "john"], ["age", 20]]
p x.inject({}){|h,k,v|h[k]=v;h}
#=> {"name"=>"john", "age"=>20}
Also #partition cannot deal with arity > 2..
All other iterator methods seems to deal ok with arity>2.
Have I forgotten any iterator methods ?
I have submitted the RCR here:
http://www.rubygarden.org/article.php?sid=333
Any thoughts ?