contract ExampleContract { uint256[] public myArray; function popAndSwap(uint256 index) public { uint256 valueAtTheEnd = myArray[myArray.length - 1]; myArray.pop(); // reduces the length; myArray[index] = valueAtTheEnd; } }
contract ExampleContract { uint256[] public myArray; function popAndSwap(uint256 index) public { uint256 valueAtTheEnd = myArray[myArray.length - 1]; myArray.pop(); // reduces the length; myArray[index] = valueAtTheEnd; } }