From: Avi Bryant Date: 2001-10-27T03:48:07+09:00 Subject: [ruby-talk:23488] Re: simplified use of map Robert Feldt wrote: >Change map to take an optional parameter which is a Symbol which >is sent to each element (as a message). >Example: >[1,2].map(:succ) #=> [2,3] >I know that you can do it with >[1,2].map {|e| e.succ} You might want to look at Marcel Weiher's Higher Order Messaging for Obj-C and Squeak... this makes use of "trampoline" objects to do the same thing like this: [1,2].map.succ #=> [2,3] It is perhaps harder to immediately understand (I find it easier for some reason in the Obj-C/Smalltalk syntax), but it has the advantage that the method being called can take parameters: ["abc", "cba"].map.tr("a", "z") #=> ["zbc", "cbz"] or even: [1,2].map + 1 #=> [2,3] or: [1..10].select < 5 #=> [1,2,3,4] It's not hard to implement; I may take a stab at it later today when I have time. Avi