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

IO#skip returns the number of bytes it skipped #9185

Closed
wants to merge 2 commits into from

Conversation

carlhoerberg
Copy link
Contributor

Can make some code much better looking, eg:

len = Int32.from_io @file
@file.skip(len)
skipped += len

can become

skipped += @file.skip(Int32.from_io(@file))

@carlhoerberg
Copy link
Contributor Author

Would also suggest increasing the buffer to 8kb as done in IO.copy. Can add it here or create another PR.

@straight-shoota
Copy link
Member

Looks good, but you'll need to add specs for this.
Buffer size should be a separate issue.

@RX14
Copy link
Contributor

RX14 commented Apr 27, 2020

For #skip I don't see the point because it's guaranteed to be the amount specified. For #skip_to_end it's definitely useful.

@carlhoerberg
Copy link
Contributor Author

Correct, but it allows for shorter user code, see example above. Do have a reason why not to return it?

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type of these methods should be UInt64. This will match #7660.

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.

4 participants