Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change readLines behaviour when reading an empty last newline #88

Merged
merged 4 commits into from
Aug 24, 2024

Conversation

Hombre-x
Copy link
Contributor

@Hombre-x Hombre-x commented Aug 23, 2024

This PR id due to a small bug that I pointed to @lenguyenthanh and @TonioGela when creating the tutorial.

Basically, calling Files[IO].writeUtf8Lines(path) will add a newline at the end of the written lines, regarding the number of elements of the collection. This will create a bug that, when using FIles[IO].readlUtf8Lines(path) will always add a new empty element to the compiled collection at the end.

So this PR changes the behaviour of the readLines method so it ignores any empty characters after the last newline, similar if you do wc -l on any file that has been written by the Files#writeUtf8Lines method.

It introduces changes on tests, as well as in the documentation.

Because readLines was modified, It now doesn't account the newline added by the writeLines method.
It now discards any empty characters after the last newline, just like the `wc` command in Unix

Also, added tests to assert that behavior
I forgot that `tempFile` does not exist anymore
@TonioGela TonioGela merged commit de57787 into davenverse:main Aug 24, 2024
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants