2

I have used the keyword delete to delete mapping and array in Remix a couple of months ago, But now I have just noticed that the keyword delete is not working at all.

Does anybody know the reason why it is not working?

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;

contract Ex {
    mapping(address => uint) public balances;
    uint[] public array = [97,98,99];
    function addBalance(address _key,uint newBalance) public {
        balances[_key] = newBalance;
    }

    function deleteBalance(address _key) public {
        delete balances[_key];
    }
    
    function deleteArray(uint _index) public {
       delete array[_index];
    }
}

1 Answer 1

1

I think it is just a remix's problem, I have tried it in truffle it was totally okay. I have just opened the issue in the remix github.

2
  • Thanks, I too, tried to figure out what was wrong here, and couldn't figure it out. For some reason, it always returns "out of Gas" whenever I try to delete.
    – Sky
    Apr 15, 2022 at 9:29
  • Np :), Good news!, it is fixed, now it is working!
    – DHC
    Apr 19, 2022 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.