From: Avi Bryant Date: 2001-10-27T10:17:11+09:00 Subject: [ruby-talk:23579] Re: simplified use of map On Sat, 27 Oct 2001, Robert Feldt wrote: > Note that in my proposal your examples would be > > ["abc", "cba"].map(:tr, "a", "x") > [1,2].map(:+, 1) > (1..10).select(:<, 5) > > which may or may not be better. Well, one reason for that way over the HOM way is that your way chains slightly better... whereas in smalltalk you have to say something like: (array select: [:x | x isEven]) collect: [:x | x * 3] or, with your way: (array select: #isEven) collect: #* with: 3 it's very nice to omit the parens and just do: array select isEven collect * 3 In Ruby that problem doesn't exist: array.select{|x| x.even?}.collect{|x| x * 3} or: array.select(:even?).collect(:*, 3) which has the advantage of: array.collect(:*, 3).select(:even?) vs: (array.collect * 3).select.even? So I'll vote for [1,2].map(:succ).