Created
September 30, 2021 09:41
-
-
Save hrkrshnn/d80199b83b903f8d6c65a2e7f5ba28dd to your computer and use it in GitHub Desktop.
An example of using calldata parameter in internal functions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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