Skip to content

Remove File.each_line method that returns an iterator#6301

Merged
sdogruyol merged 1 commit into
crystal-lang:masterfrom
asterite:refactor/6087-remove-file-each-line
Jul 3, 2018
Merged

Remove File.each_line method that returns an iterator#6301
sdogruyol merged 1 commit into
crystal-lang:masterfrom
asterite:refactor/6087-remove-file-each-line

Conversation

@asterite
Copy link
Copy Markdown
Member

Fixes #6087

There's already IO#each_line which returns an iterator, so one can simply do:

File.open(filename) do |file|
  file.each_line.more_iterator_methods
end

and be sure the file is closed.

And I was wrong, there's no class method File.each_line in Ruby.

@RX14 RX14 added topic:stdlib breaking-change May have breaking effect in some edge cases. Mostly negligible, but still noteworthy. labels Jun 30, 2018
@RX14 RX14 added this to the 0.26.0 milestone Jun 30, 2018
@sdogruyol sdogruyol merged commit fafdd63 into crystal-lang:master Jul 3, 2018
@RX14
Copy link
Copy Markdown
Member

RX14 commented Jul 3, 2018

I was waiting to merge this until after 0.25.2 since it's a breaking change.

@asterite asterite deleted the refactor/6087-remove-file-each-line branch July 6, 2018 22:56
vladfaust added a commit to vladfaust/migrate.cr that referenced this pull request Aug 14, 2018
BREAKING CHANGE: `File.each_line(path)` is no longer valid in Crystal since 0.26.

See crystal-lang/crystal#6301
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change May have breaking effect in some edge cases. Mostly negligible, but still noteworthy. topic:stdlib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calling File.each_line Iterator method doesn't close File

3 participants