Index

Solidity

  1. types
  2. External
  3. Library
    1. self in Library
    2. using * for
    3. self example
  4. interfaces
  5. import
  6. msg.value
  7. Handling ether
  8. Erc20 token in contract
  9. assembly
  10. Enum
  11. memory, storage, calldata
  12. Array Pushing
  13. length in array
  14. Struct array
  15. mapping
  16. bytes and string
  17. uint to bytes32
  18. returns with name
  19. score voting
  20. Tests
    1. Async Tests
    2. Hooks

memory, storage, calldata

https://ethereum.stackexchange.com/questions/63247/calldata-keyword-as-parameter-in-solidity-v0-5-0-function

As 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;
  }

}