- Define function types as either internal or external functions. These types can be used as a parameter while calling a function or while returning from a function:
function function_name(<function_type_parameters>) <internal | external> <pure | view | payable> returns (<function_return_types>) { // ...}
Internal functions can only be called inside the current contract. External functions can be passed via, and returned from, external function calls. It consists of an address and a function signature.
- Create a function that accepts a uint and a function type. Let's call the uint num and the function type fun. For this example, make the function type accept a uint and return a uint:
function calculate ( uint num, // uint ...