Created
January 29, 2022 20:53
-
-
Save raj-pranav/fff69c99ff8fb1d6ae172aa86b13d077 to your computer and use it in GitHub Desktop.
Functions in Solidity
This file contains 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
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity >=0.5.0 <0.9.0; | |
// code for view type function | |
contract sample { | |
uint s = 10; | |
function f_name(uint _a) public view returns (uint) { | |
return _a + block.number; | |
} | |
} | |
// code for pure type function | |
contract sample_pure { | |
function sample_p (uint _age) public pure returns (bool) { | |
if (_age > 60) // to check senior citizen | |
return true; | |
else | |
return false; | |
} | |
} | |
// One liner function | |
contract Test { | |
function f(uint a) private pure returns (uint) { return a + 1; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment