#On Behalf Of Eero Saynatkari
#>>"12345".collect { |x| x.to_i}
#> ==> [12345] # instead of the expected [1,2,3,4,5].
#>
#> Am I misunderstanding how include works in this case? Thanks alot.
···
#
#The reason for this is that Enumerable merely wraps the
#object's #each method. In the case of String, #each by
#default splits the string at each line (as determined
#by the record separator constant $/).
is it possible to pass a param for collect/map to signal the separator (akin to split)? eg
"12345".collect(//) { |x| x.to_i}
==> [1, 2, 3, 4, 5]
and noting that
"12345".split(//).collect{|x| x.to_i}
=> [1, 2, 3, 4, 5]
kind regards -botp