Skip to content

Instantly share code, notes, and snippets.

@hrkrshnn
Created September 30, 2021 09:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrkrshnn/d80199b83b903f8d6c65a2e7f5ba28dd to your computer and use it in GitHub Desktop.
Save hrkrshnn/d80199b83b903f8d6c65a2e7f5ba28dd to your computer and use it in GitHub Desktop.
An example of using calldata parameter in internal functions.
contract C {
function f(uint[] calldata arr) external returns(uint) {
return sum(arr);
}
function sum(uint[] calldata arr) internal returns(uint _sum) {
for(uint i = 0; i < arr.length; i++) {
_sum += arr[i];
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment