From: Ben Weissmann Date: 2013-01-24T13:39:08+09:00 Subject: [ruby-core:51614] Inconsistency between Enumerable#map and Enumerable#select --20cf306f720ce0e33304d40163dd Content-Type: text/plain; charset=ISO-8859-1 Hey all, I've found an inconsistency between Enumerable#map and Enumerable#select, and i'm wondering what the rationale behind it is: a = ['a', 'b', 'c'] a.each_with_index.select{|pr| p pr} # prints: # ["a", 0] # ["b", 1] # ["c", 2] a.each_with_index.map{|pr| p pr} # prints: # "a" # "b" # "c" I've posted this question to StackOverflow [1], and the responses point to a difference between the implementation of select and map in both MRI and Rubinius. Is there a rationale for this difference, and is there documentation for which Enumerable methods use which implementation? Thanks, Ben bsw@mit.edu [1] http://stackoverflow.com/questions/14492882/chaining-enumerators-that-yield-multiple-arguments --20cf306f720ce0e33304d40163dd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hey all,

I've found an incons= istency between Enumerable#map and Enumerable#select, and i'm wondering= what the rationale behind it is:

a =3D ['a', 'b', 'c']

a.ea= ch_with_index.select{|pr| p pr}
# prints:
# ["a&qu= ot;, 0]
# ["b", 1]
# ["c", 2]

a.each_with_index.map{|pr| p pr}
# prints:
# "a"
# "b"
# "c"=

I've posted this question to StackOverf= low [1], and the responses point to a difference between the implementation= of select and map in both MRI and Rubinius. Is there a rationale for this = difference, and is there=A0documentation=A0for which Enumerable methods use= which implementation?

Thanks,
Ben
bsw@mit.edu

<= div style>[1]=A0http://stackoverflow.com/qu= estions/14492882/chaining-enumerators-that-yield-multiple-arguments
--20cf306f720ce0e33304d40163dd--