Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In Ruby 2.0, String#lines returns an Array, rather than an Enumerator #945

Merged
merged 1 commit into from Aug 4, 2013
Merged

In Ruby 2.0, String#lines returns an Array, rather than an Enumerator #945

merged 1 commit into from Aug 4, 2013

Conversation

@Sinjo
Copy link
Contributor

@Sinjo Sinjo commented Aug 4, 2013

Ruby 2.0 has changed the return type of String#lines to Array, from Enumerator. The difference in behaviour between MRI 2.0.0 and JRuby 1.7.4 with the --2.0 argument supplied is:

In MRI 2.0.0-p247:
sinjo@widdershins:~/projects/jruby-file-encoding$ rvm use 2.0.0
Using /home/sinjo/.rvm/gems/ruby-2.0.0-p247

sinjo@widdershins:~/projects/jruby-file-encoding$ ./demo input_file.txt 
["first line\r\n", "second line\r\n", "third line"]
"first line\r\n"

-----

In JRuby 1.7.4 with JRUBY_OPTS=--2.0:
sinjo@widdershins:~/projects/jruby-file-encoding$ rvm use jruby
Using /home/sinjo/.rvm/gems/jruby-1.7.4

sinjo@widdershins:~/projects/jruby-file-encoding$ ./demo input_file.txt 
[#<Enumerator: "first line\r\nsecond line\r\nthird line":lines>]
#<Enumerator: "first line\r\nsecond line\r\nthird line":lines>

Output taken from this gist

headius added a commit that referenced this pull request Aug 4, 2013
In Ruby 2.0, String#lines returns an Array, rather than an Enumerator
@headius headius merged commit 436b5f7 into jruby:master Aug 4, 2013
1 check passed
1 check passed
@veganstraightedge
default The Travis CI build passed
Details
@headius
Copy link
Member

@headius headius commented Aug 4, 2013

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants