<p>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 <code>delete arr[ind]</code> does not rearrange the array but only resets the array element.</p>

CC BY-SA 3.0
2015-06-22T09:54:47.020Z
2015-06-22T09:54:47.020Z
chriseth
<p>Refer to <a href="https://github.com/ethereum/wiki/wiki/Solidity-Tutorial#arrays" rel="nofollow">the documentation</a>:</p>

<pre><code>delete myArray[arrayIndex];
</code></pre>

CC BY-SA 3.0
2015-06-22T05:51:15.717Z
2015-06-22T15:00:04.470Z
2015-06-22T15:00:04.470Z
cryptoInnovator
<p>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 <a href="https://github.com/ethereum/wiki/wiki/Solidity-Tutorial" rel="nofollow">some of the documentation</a>, I can't seem to find any good way of doing this.</p>

<raw-data><ethereum><smartcontracts>
How to delete an element of an array in an Ethereum contract?
ThePiachu
# How to delete an element of an array in an Ethereum contract?

(Asked by: username_0 on 2015-06-22)

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](https://github.com/ethereum/wiki/wiki/Solidity-Tutorial), I can't seem to find any good way of doing this.

**Tags:** raw-data, ethereum, smartcontracts


---

## 2 answers

### Answer by username_1 on 2015-06-22. Score: 2 | Accepted answer

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.


---

### Answer by username_2 on 2015-06-22. Score: 4

Refer to the documentation:
delete myArray[arrayIndex];


---

