-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Add Array.slice
and Array.splice
for value type arrays
#5965
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
base: master
Are you sure you want to change the base?
Add Array.slice
and Array.splice
for value type arrays
#5965
Conversation
🦋 Changeset detectedLatest commit: 38e8e88 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Array.slice
and Array.splice
for value type arrays
Walkthrough
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The only downside of this PR is that we'd need to bump pragma of Arrays.sol to 0.8.24 to support |
This PR implements JavaScript-like
slice
andsplice
functions for value type arrays (uint256[]
,bytes32[]
,address[]
) in the OpenZeppelin Arrays library.Key features:
slice
: Creates a new array containing elements from a specified range (non-mutating)splice
: Modifies the original array in-place, keeping elements from a specified range (mutating)mcopy
instruction for efficient array operationsBreaking change: Requires pragma bump to
^0.8.24
for Arrays and all dependent contracts to support themcopy
instruction.This addresses issue #5723 and provides developers with familiar array manipulation utilities similar to JavaScript's Array methods.
PR Checklist
npx changeset add
)