Created
August 14, 2013 01:49
-
-
Save domgetter/6227367 to your computer and use it in GitHub Desktop.
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
file = File.new("testfile.txt", "r") | |
file.pos | |
=> 0 | |
file.gets | |
=> "This is line one\n" | |
file.pos | |
=> 18 | |
#This reports 18, but there are clearly 17 characters in that line. | |
# In fact, if you capture the gets to a variable, it reports its length correctly | |
file.rewind | |
=> 0 | |
a = file.gets | |
=> "This is line one\n" | |
a.length | |
=> 17 | |
file.pos | |
=> 18 | |
# Is this expected behavior? | |
# I'm running ruby 2.0.0p247 (2013-06-27) [i386-mingw32] | |
# on Win7 64bit if that helps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment