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

name of variable "line" misleading in exercises on io #548

Open
samuelpath opened this issue Aug 2, 2017 · 4 comments
Open

name of variable "line" misleading in exercises on io #548

samuelpath opened this issue Aug 2, 2017 · 4 comments

Comments

@samuelpath
Copy link

Hi,

In the solutions to the exercises my_first_io and my_first_async_io, the variable to count the number of newlines is called "lines".

This is misleading since we are not counting the number of lines per se but rather the numbre of newlines, which are two different things.

e.g.

line 1 \n
line 2 \n
line 3

In the example above, we have 3 lines but only 2 newlines.

If I'm correct, we should find a better name for the variable.
If not, could you explain what I've missed?

Cheers,
Samuel

@AnshulMalik
Copy link
Contributor

I see it's newlines in https://github.com/workshopper/learnyounode/blob/master/exercises/my_first_io/problem.md

Can you point me to the file where it is line?

@samuelpath
Copy link
Author

@AnshulMalik
Copy link
Contributor

The solutions seems fine to me

@mikematthews
Copy link

This is setting us up for a fencepost error:
similar to running cat file | wc -l.
If you have a 3-line file without a newline at the end, wc -l will still return 3 because it's counting lines, not newlines.

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

No branches or pull requests

3 participants