Arr::of() & Arrayable instance #40898
-
since we have Stringeable and we can do Str::of('hello') I thought it would be convenient to have Arr::of($array)
//so instead of
Arr::first($names, fn($name) => $name == 'ahmed');
//it will be
Arr::of($names)->first(fn ($name) => $name === 'ahmed'); the motivation behind this is I tried to add arr() helper method same as str() but couldn't do it cause we don't have Arrayable class like Stringable |
Beta Was this translation helpful? Give feedback.
Answered by
ralphjsmit
Feb 11, 2022
Replies: 1 comment 4 replies
-
Can’t you just use a collection for that? collect($names)->first(fn ($name) => $name === ‘ahmed’);
collect($names)->firstWhere(‘name’, ‘ahmed’); |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
amaelftah
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can’t you just use a collection for that?