From: Matthew Kerwin Date: 2014-01-31T16:37:04+10:00 Subject: [ruby-core:60372] Re: [ruby-trunk - Feature #8987] map/collect extension which handles arguments --001a11c1707ef66c3104f13e664d Content-Type: text/plain; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable On 31 January 2014 15:48, SASADA Koichi wrote: > p [1, 2, 3, 4].map(&4.method(:+)) #=3D> [5, 6, 7, 8] > p [1, 2, 3, 4].map(&=EB{|x| 4+x}) #=3D> [5, 6, 7, 8] > p [1, 2, 3, 4].map(&=EB(4, :+)) #=3D> [5, 6, 7, 8] > p [1, 2, 3, 4].map(&=EB("4+")) #=3D> [5, 6, 7, 8] > p [1, 2, 3, 4].map(&=EB{4+_}) #=3D> [5, 6, 7, 8] (doesn't run) > Are any of these actually better than: p [1, 2, 3, 4].map{|x| 4+x } ? --=20 Matthew Kerwin http://matthew.kerwin.net.au/ --001a11c1707ef66c3104f13e664d Content-Type: text/html; charset=ISO-8859-7 Content-Transfer-Encoding: quoted-printable
= On 31 January 2014 15:48, SASADA Koichi <ko1@atdot.net> wrote:
=A0 = =A0 p [1, 2, 3, 4].map(&4.method(:+)) #=3D> [5, 6, 7, 8]
=A0 =A0 p [1, 2, 3, 4].map(&=EB{|x| 4+x}) =A0#=3D> [5, 6, 7, 8]
=A0 =A0 p [1, 2, 3, 4].map(&=EB(4, :+)) =A0 =A0#=3D> [5, 6, 7, 8] =A0 =A0 p [1, 2, 3, 4].map(&=EB("4+")) =A0 =A0 #=3D> [5, 6= , 7, 8]
=A0 =A0 p [1, 2, 3, 4].map(&=EB{4+_}) =A0 =A0 =A0#=3D> [5, 6, 7, 8] = (doesn't run)

Are any of these actually better than:

=A0 =A0 p [1, 2, 3, 4= ].map{|x| 4+x }

?


--
--001a11c1707ef66c3104f13e664d--