Functions
Function Declarations
function functionName(parameterList): ReturnType {
// Function body
}parameterListis a comma-separated list of parameters with their types.ReturnTypeis optional; if omitted, the function does not return a value.
Parameters
Parameters are declared with their name and type.
function add(a: uint256, b: uint256): uint256 {
return a + b;
}Return Types
Specify the return type after the parameter list and a colon.
function isPositive(number: uint256): bool {
// Function body
}Note: The bool type may not be fully implemented yet; currently, functions can return uint256.
Return Statements
Use the return keyword to return a value from a function.
Last updated