Help me understand Data location

LocoLoco Member Posts: 1
I read http://solidity.readthedocs.org/en/latest/types.html#data-location a couple of times. It's still not clear what is the difference between storage and memory. Where physically it's located? What is the difference between local and state variables, function parameters and function arguments?

I have an example of contract:
contract MultiAssetContract {

    struct Asset {
        bytes32 symbol;
        uint8 baseUnit;
        bytes32 name;
        bytes32 description;
        mapping (address => uint) index;
        address[] holders;
        uint[] amounts;
    }
    
    mapping(bytes32 => uint) public assetIndex;
    Asset[] public assets;

    function issueAsset() returns (bool) {
        bytes32 symbol = "LCC";

        if (assetIndex[symbol] > 0) {
            return false;
        }
        uint pos = assets.length++;

        address[] memory addresses;
        uint[] memory amounts;

        assets[pos] = Asset({
            symbol: symbol,
            holders: addresses,
            amounts: amounts,
            name: "LocoCoin",
            description: "My coins",
            baseUnit: 1
        });

        return true;
    }
}
Contract is successfully compiled and deployed. However issueAsset() never works due to

address[] memory addresses;
uint[] memory amounts;
....
holders: addresses,
amounts: amounts,

There are no errors, it's just don't work. I assuming it's because the arrays are not initialized but why there are no errors or compile warnings?
Correct code is:
holders: new address[](2),
amounts: new uint[](2),
How Solidity behaves here?
Sign In or Register to comment.