Index
memory, storage, calldata
https://ethereum.stackexchange.com/questions/63247/calldata-keyword-as-parameter-in-solidity-v0-5-0-functionAs per the Solidity version 0.5.0 breaking changes here :
Explicit data location for all variables of struct, array or mapping types, bytes, string is now mandatory. This is also applied to function parameters and return variables.
Note:
For bytes32 its not giving error.
So currently, reference types comprise structs, arrays and mappings. If you use a reference type, you always have to explicitly provide the data area where the type is stored:
• memory (whose lifetime is limited to a function call)
• storage (the location where the state variables are stored)
• calldata (special data location that contains the function arguments, only available for external function call parameters).
So here in the shared contract, data location has been mentioned which is
calldata
. Hope it helps.Example as return values:
See the get_a() function
contract ArrayPushing {
uint[] a = new uint[](0);
function f (uint len) public {
a.push(len);
}
function get_a() public view returns (uint[] memory) {
return a;
}
}