Actions
Bug #15001
closedPeek causes cursor to advance when enumerating the lines of a file
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
Description
When a call to peek is made on the enumerator for the lines of a file the cursor advances.
File:
1
2
3
Sample script:
e = File.open("f").each_line
e.peek
p e.each.to_a
The output is => ["2\n", "3\n"]
The expected output is => ["1\n", "2\n", "3\n"]
When performing the same operation on a string we get the expected output.
e = "1\n2\n3\n".each_line
e.peek
p e.each.to_a
The output is: => ["1\n", "2\n", "3\n"]
Actions
Like0
Like0Like0Like0Like0