What does the memory keyword in the argument of a function do?
pragma solidity 0.4.24;
pragma experimental "ABIEncoderV2";
contract Conditional {
struct Condition {
address to;
bytes4 selector;
bytes parameters;
bytes32 expectedValueHash;
bool onlyCheckForSuccess;
}
function isSatisfied(Condition memory condition)
public
view
returns (bool)
{
if (condition.onlyCheckForSuccess) {
return assertNotFails(condition);
} else {
return assertReturnsExpectedResult(condition);
}
}
I understand what the memory keyword does. But what does it mean in the context of a function argument?
Best Answer
If you don't specify storage type of a function argument then function arguments are always in memory and you are passing an argument to a function by value.
When you are explicitly defining storage type of an argument as
storage
you are passing an argument to a function by reference.