From: Rick DeNatale Date: 2009-08-29T22:58:43+09:00 Subject: Re: #map, #select semantics On Sat, Aug 29, 2009 at 9:25 AM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: #map, #select semantics" >    on Sat, 29 Aug 2009 21:32:21 +0900, 7rans writes: > > |Let's say we have > | > |  [[:a,1], [:b,2]].map{ |(k,v)| [k, v+1] }  #=> [[:a,2], [:b,3]] > | > |We might have something like: > | > |  [[:a,1], [:b,2]].using({}).map{ |(k,v)| [k, v+1] }  #=> {:a=>2, :b=>3} > > [[:a,1], [:b,2]].inject({}){|h,(k,v)| h[k]=v+1; h}     #=> {:a=>2, :b=>3} +1 Proving that inside every map there's an inject struggling to break free! Seriously, although my Smalltalk background gives me a philosophical preference for having ruby enumeration work more like Smalltalk, from a pragmatic perspective, I'd prefer it if changes wouldn't break my existing code. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale