Gregory Brown wrote:
> But this may be to preserve compatibility with Ruby 1.8.6:
Ah, that's a good enough reason.
'ri Array#map' from 1.8.6 doesn't mention the possibility that it could
be used without a block, which led me off the scent.
-------------------------------------------------------------- Array#map
array.collect {|item| block } -> an_array
array.map {|item| block } -> an_array
------------------------------------------------------------------------
Invokes _block_ once for each element of _self_. Creates a new
array containing the values returned by the block. See also
+Enumerable#collect+.
a = [ "a", "b", "c", "d" ]
a.collect {|x| x + "!" } #=> ["a!", "b!", "c!", "d!"]
a #=> ["a", "b", "c", "d"]
--
Posted via http://www.ruby-forum.com/.