-
-
Notifications
You must be signed in to change notification settings - Fork 814
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
methods for modifying dynamic arrays #2611
Comments
I would like to also suggest a |
What would the semantics of this method be? |
Ah, sorry. I mean a method that would remove all elements from the given array, resetting its length to 0. |
Sorry, I guess it would be presumably be named whatever the analogous thing is in Python; I just suggested the first name that came to mind, I didn't think about what the naming convention here is! |
You can set the length of a dynamic array to zero by either using an empty list literal or using the special empty function my_array: DynArray[uint256, 7] = [ 1,2,3]
my_array.pop()
my_array = [] # set length to zero
my_array = empty(DynArray[uint256,7]) # same thing |
Oh, sorry, I had no idea all that was legal! Disregard my request, then. Thanks! |
current master only has assignment between dynamic arrays, but people will expect to be able to modify arrays. we should implement modifier methods. to be familiar for python users:
.append()
push()
, but it changes the runtime length of the array).pop()
pop()
but it changes the runtime length of the array.extend()
.pop(ix=?)
The text was updated successfully, but these errors were encountered: