Answers for "how to move all element in array solidity"

0

how to move all element in array solidity

contract test{
    uint[] array = [1,2,3,4,5];
    function remove(uint index)  returns(uint[]) {
        if (index >= array.length) return;

        for (uint i = index; i<array.length-1; i++){
            array[i] = array[i+1];
        }
        delete array[array.length-1];
        array.length--;
        return array;
    }
}
Posted by: Guest on June-27-2021

Code answers related to "how to move all element in array solidity"

Browse Popular Code Answers by Language