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/chaini...
on 2013-01-24 05:39
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.