The basic syntax of a custom function is consistent with the syntax of a general computer language, such as:
<datatype> <variable> = <expression>
| Syntax | Description |
| -------- | ----------------------------------------- -------------------- |
| Data type | Provide 12 major data types in the custom function, for details, please refer to the data type chapter (case-sensitive) |
| variable | is the name of the data, which is used for subsequent logic calls, and can be customized (not the same as the data type) |
| expression | that is, the value assigned to the variable, which can be directly defined or an expression (if it is an expression, please note that the return value type of the expression must be consistent with the data type, otherwise an error will be reported) |
**Note: **The data type can be represented by def in the custom function, and the data type will be automatically recognized at compile time
Example:
> String str = "fxiaoke" //is directly defined
> Boolean boo = ["red", "blue", "green", "yellow"].isEmpty() //expression definition
> def result = ["red", "blue", "green", "yellow"].isEmpty() //def indicates the data type