Skip to content

[9.x] Adds Arr::map and Arr::transform#42398

Merged
taylorotwell merged 2 commits intolaravel:9.xfrom
ecrmnn:arr-map
May 16, 2022
Merged

[9.x] Adds Arr::map and Arr::transform#42398
taylorotwell merged 2 commits intolaravel:9.xfrom
ecrmnn:arr-map

Conversation

@ecrmnn
Copy link
Copy Markdown
Contributor

@ecrmnn ecrmnn commented May 16, 2022

Adds Arr::map and Arr::transform.

I've finally created a PR for this after assuming it's there for a while.
Everytime I realize it's not, I'm wrapping my array in a collection to get that sweet syntactic sugar 🍬

  • Significantly better syntax than array_map
  • Iterates both values and keys out of the box
  • Consistent API with Collection
  • Refactored Collection to consume Arr::map

Added Arr::transform because they're basically the same, except $array is passed by reference.

@ecrmnn ecrmnn marked this pull request as ready for review May 16, 2022 13:29
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.

2 participants