Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Close the file after reading#7

Merged
appgurueu merged 1 commit intoappgurueu:masterfrom
NobWow:master
Jul 17, 2022
Merged

Close the file after reading#7
appgurueu merged 1 commit intoappgurueu:masterfrom
NobWow:master

Conversation

@NobWow
Copy link
Contributor

@NobWow NobWow commented Jul 17, 2022

the file must be closed otherwise on Unix systems it creates an overflow

@appgurueu
Copy link
Owner

Technically garbage collection should eventually close the file:

Closes file. Note that files are automatically closed when their handles are garbage collected, but that takes an unpredictable amount of time to happen.

But it's definitely a code smell that I forgot to close it here, and as the reference manual states this can't be relied on.

Thanks for your PR!

@appgurueu appgurueu added the fix Fixes a bug label Jul 17, 2022
@appgurueu
Copy link
Owner

Now that I see what I'm doing there: I should probably have avoided this altogether by using io.lines.

@appgurueu appgurueu merged commit 9f65d5d into appgurueu:master Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants