-
Hi, I am in Patrick's video. In functions, when they say return in the beginning, I need to return something right? In this function, it is not erroring and I don't know why.
I don't need to say return to those two variables??? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hello @h0leee If you are doing below: function checkUpkeep(bytes memory /* checkData */) public view override returns (bool upkeepNeeded, bytes memory /* performData */) You are basically declaring that this function will return 2 variables: bool and bytes type. If you declare that it will return some variables you must return them at the end of this function. If you won't return them it should throw error. |
Beta Was this translation helpful? Give feedback.
-
In that case, you gave the return variable names in the declaration, so there's no need for a return statement.
|
Beta Was this translation helpful? Give feedback.
@h0leee
In that case, you gave the return variable names in the declaration, so there's no need for a return statement.
function foo() public pure returns (uint256) { return 5}
is equivalent to
function foo() public pure returns (uint256 x) { X = 5 }