Skip to content

[10.x] Introduce new Arr::take() helper #50015

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

Merged
merged 2 commits into from
Feb 9, 2024
Merged

[10.x] Introduce new Arr::take() helper #50015

merged 2 commits into from
Feb 9, 2024

Conversation

ryangjchandler
Copy link
Contributor

I reached for this today and could have sworn that it existed, but turns out that it's only a Collection method. I think it makes sense as an Arr helper too, since it reads a lot nicer than the underlying array_slice() syntax.

@taylorotwell
Copy link
Member

I don't see a limit collection method?

@ryangjchandler
Copy link
Contributor Author

ryangjchandler commented Feb 9, 2024

Ah, yeah not limit(), take() is the correct method name inside of Collection.

I can rename for consistency with the collection method, if preferred?

@taylorotwell
Copy link
Member

Yeah I think that would be good.

@ryangjchandler
Copy link
Contributor Author

@taylorotwell All done :^)

@ryangjchandler ryangjchandler changed the title [10.x] Introduce new Arr::limit() helper [10.x] Introduce new Arr::take() helper Feb 9, 2024
@taylorotwell taylorotwell merged commit 0a8c91b into laravel:10.x Feb 9, 2024
@taylorotwell
Copy link
Member

Thanks!

@ryangjchandler ryangjchandler deleted the Arr-limit branch February 9, 2024 16:07
@decadence
Copy link
Contributor

Note: this doesn't preserve array keys while Collection::take does

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