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

Last should accept 0 as limit #6419

Closed
BaibhaVatsa opened this issue Oct 11, 2019 · 2 comments · Fixed by #6420
Closed

Last should accept 0 as limit #6419

BaibhaVatsa opened this issue Oct 11, 2019 · 2 comments · Fixed by #6420

Comments

@BaibhaVatsa
Copy link
Contributor

Issue description

Currently, Last throws an error if 0 is passed as a limit even though that usage should not crash things.
Further, first accepts 0 as a value for limit and returns an empty slice in that case so for consistency last should also accept 0 as limit.

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.59.0-DEV-096A4B67 linux/amd64 BuildDate: 2019-10-11T02:36:33-0500

Does this issue reproduce with the latest release?

Yes

@bep bep added this to the v0.59 milestone Oct 11, 2019
@bep
Copy link
Member

bep commented Oct 11, 2019

I agree. I labeled this as an Enhancement, as I guess there are test cases for it. But you are right, what you say makes much more sense.

BaibhaVatsa added a commit to BaibhaVatsa/hugo that referenced this issue Oct 11, 2019
Modified the if conditional because of which last threw an error if 0 was passed as limit. The function now returns an empty slice if it is called with 0 as limit. The behavior of first and last is now the same when 0 is passed as limit. Also added tests to test the new behavior.

Fixes gohugoio#6419
@bep bep closed this as completed in #6420 Oct 11, 2019
bep pushed a commit that referenced this issue Oct 11, 2019
Modified the if conditional because of which last threw an error if 0 was passed as limit. The function now returns an empty slice if it is called with 0 as limit. The behavior of first and last is now the same when 0 is passed as limit. Also added tests to test the new behavior.

Fixes #6419
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants