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

Using the splat operator (...) to copy an array #1528

Closed
AlexandruGG opened this issue Jul 2, 2021 · 2 comments · Fixed by #1529
Closed

Using the splat operator (...) to copy an array #1528

AlexandruGG opened this issue Jul 2, 2021 · 2 comments · Fixed by #1529

Comments

@AlexandruGG
Copy link
Contributor

Hello!

Is your feature request related to a problem? Please describe.
Copying an array using the ... operator is different from copying via assignment because the array pointer is maintained in the second case. It would be great if there would be a mutator which switches one for the other.

Describe the solution you'd like

$array = [1, 2, 3];
$array2 = [...$array]; // -> this could be mutated to $array2 = $array;

Additional context
See example here, I hope this clarifies what I mean: https://3v4l.org/gfW5D#v8.0.8

I noticed there is already a Spread Mutator so I thought this could be something similar to that one, let me know if this makes sense.

@maks-rafalko
Copy link
Member

Hi, thanks for this feature request. You are very welcome to implement it, shouldn't be hard :)

@AlexandruGG
Copy link
Contributor Author

I'm going to try get familiar with the codebase and give it a shot 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants