Functions
Function Definition
You define functions with the function
method with the following signature:
For example:
Parameters
:function_name
- The name of the function{arg1: :type1, arg2: :type2, ...}
- A hash of argument names to types.*options
- Zero or more flags that specify additional function characteristics like visibility (:public
,:private
), state mutability (:view
,:pure
), etc.returns: return_type
- Specifies the return type.
Inside the Function Body
s.variableName
can be used to read from and write to state variables.If you write an identifier like
variableName
without thes.
prefix, the system will look for it among the function's arguments first, and then among the contract's functions.
Automatically Generated Functions
If you have a public state variable, a getter function is automatically generated. So, there's no need to write a separate getter function for that variable.
Last updated