# Re: Included modules and String

**URL:** <https://www.ruby-forum.com/t/re-included-modules-and-string/51281>\
**Category:** Ruby\
**Created:** [December 29, 2005, 2:25am UTC](https://www.ruby-forum.com/t/re-included-modules-and-string/51281 "2005-12-29T02:25:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SSSutf-8SBSUGXDsWEs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6de8d8/32.png) [@SSSutf-8SBSUGXDsWEs](https://www.ruby-forum.com/u/SSSutf-8SBSUGXDsWEs)\
**Post date:** [December 29, 2005, 2:25am UTC](https://www.ruby-forum.com/t/re-included-modules-and-string/51281/1 "2005-12-29T02:25:41Z")

</div>

#On Behalf Of Eero S.

#\>\>“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
