2

I am wondering - is it possible to delete a single element of an array in Ethereum without having to create a new array and copying the entire array? Reading some of the documentation, I can't seem to find any good way of doing this.

2

If you want the operation of removing an element from a list to be efficient (i.e. without having to copy the list), you have to use a different data structure, e.g. a linked list or a mapping with a reverse index. Note that delete arr[ind] does not rearrange the array but only resets the array element.

| improve this answer | |
4

Refer to the documentation:

delete myArray[arrayIndex];
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.