Golo modules can define functions as follows:
module sample function hello = { return "Hello!" }
In turn, you may invoke a function with a familiar notation:
let str = hello()
A function needs to return a value using the return
keyword. Some
languages state that the last statement is the return value, but Golo
does not follow that trend. We believe that return
is more explicit,
and that a few keystrokes in favour of readability is still a good deal.
Still, you may omit return
statements if your function does not return
a value:
function printer = { println("Hey!") }
If you do so, the function will actually return null
, hence result
in the next statement is null
:
# result will be null let result = printer()