1

This post (When should I use calldata and when should I use memory?) explains the differences between calldata and memory. However where are function arguments or variables within functions stored if nothing is specified aka what is the default for each?

Examples:

function foo(string _exampleString) // where is the argument stored?

vs

function foo(string memory _exampleString)

or

function foo(string _exampleString) public{
   uint256 memory bar = 1;
}

vs

function foo(string _exampleString) public { uint256 bar = 1; // where is the argument stored? }

1 Answers1

0

As you can read on this documentation function arguments are always in memory. So both options will store the value on memory.

Julissa DC
  • 1,888
  • 1
  • 8
  • 21
  • that doesn't really answer my question. My question is why would you specify memory to a function argument if its the default place to be stored? why would you speciy calldata explicitly? Besides funciton arguments can also be stored in storage – Friedrich Coen Nov 12 '21 at 15:20