Anyone know how to delete an element in a array? Is there any built in method to do that?
If not, does anyone know of how to implement such a method?
contract-developmentsolidity
Anyone know how to delete an element in a array? Is there any built in method to do that?
If not, does anyone know of how to implement such a method?
Best Answer
Use the
delete
operator to delete the element:If you don't want to leave a gap, you need to move each element manually:
If you don't care about the order, you can also just copy the last element into the empty spot, then delete the last element.