From: "David A. Black" Date: 2009-08-30T00:13:23+09:00 Subject: Re: #map, #select semantics --1926193751-239797047-1251558786=:3838 Content-Type: MULTIPART/MIXED; BOUNDARY="1926193751-239797047-1251558786=:3838" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1926193751-239797047-1251558786=:3838 Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8BIT Hi -- On Sat, 29 Aug 2009, Rick DeNatale wrote: > 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. Does that mean that if I learn Smalltalk, I have to want it to be more like Ruby? :-) (I know, I know.) David -- David A. Black / Ruby Power and Light, LLC / http://www.rubypal.com Ruby/Rails training, mentoring, consulting, code-review Latest book: The Well-Grounded Rubyist (http://www.manning.com/black2) September Ruby training in NJ has been POSTPONED. Details to follow. --1926193751-239797047-1251558786=:3838-- --1926193751-239797047-1251558786=:3838--