Last active
December 20, 2015 11:39
-
-
Save Sinjo/6125035 to your computer and use it in GitHub Desktop.
JRuby 1.7.4 bug in --2.0 mode JRuby returns an Enumerator. This was the 1.9.3 behaviour, but in 2.0.0 MRI changed to returning an array.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
lines = ARGV.flat_map { |file_name| File.open(file_name, 'r:bom|utf-8') { |file| file.read.lines } } | |
p lines | |
p lines.first | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment