fun (function)
Defines your own command.
Syntax
fun name(p: Type): ReturnType { return ... }Description
Defined with fun; the return type is written with a colon (:). Single-expression functions can be written with an equals sign (=): fun square(x: Int) = x * x.
Example
Loading editor…
This language is for reference/learning only — copy the code and try it in your own environment.
Expected output
25
When to use?
Preventing code repetition, breaking the program into parts.