Thu Mar 30 2023 10:03:02 GMT+0000 (Coordinated Universal Time)
Saved by @RareSkills
contract ExampleContract { uint256[] public myArray; function popAndSwap(uint256 index) public { uint256 valueAtTheEnd = myArray[myArray.length - 1]; myArray.pop(); // reduces the length; myArray[index] = valueAtTheEnd; } }
Copy this HTML code:
Preview:
open_in_newInstructions on embedding in Medium
Comments