Code has been added to clipboard!

Solidity Operators Involving LValues Example

Example
pragma solidity ^0.4.0;

contract exampleDelete {
    uint arrayData;
    uint[] exampleArray;

    function f() {
        uint x = arrayData;
        delete x; // sets x to 0, has no effect on arrayData
        delete arrayData; // this will set arrayData to 0, but not affect x which will still hold a copy
        uint[] y = exampleArray;
        delete exampleArray; // this would set dataArray.length to zero, however, as uint[] is a complex object,
        // y is affected too, it being an alias to the storage object
        // Despite this, "delete y" is not a valid statement, since assignments to local variables
        // that reference storage objects may only be made from pre-existing storage objects.
    }
}