Functions
Description of functions in Drizzle

Functions

Functions in Drizzle are defined using the def keyword.
1
def multiply_message(msg: str, times: int = 5) {
2
to_print = msg * times
3
println(to_print)
4
}
5
6
# In this example we show that Drizzle supports default params
7
multiply_message('a') # Prints 'aaaaa'
8
multiply_message('a', 3) # Prints 'aaa'
Copied!

Single Line Functions

Drizzle also supports simple one line functions;
1
def multiply_message(msg: str, times: int = 5) = println(msg * times)
Copied!

Return Types

Return types of the function are shown through the use of the -> operator
1
def test() -> int = return 3
Copied!
If no return type is explicitly described, the null type is assumed to be the return type. The null type is returned from a function in 3 cases: 1. When there's no return statement in the function. 2. When there's an empty return statement in the function. 3. When null is explicitly returned from the function.