From Onix OS Wiki
Jump to: navigation, search

In this section we will see how to define and use functions. If you looked at the Definitions section, you've learned how to define it. A function can be defined as a function. And it should not be confused with "Literals".


def object = fn(args...){
...other lines...

Here, your object is now a function and is defined in the function. To use this function, simply call it with the name of the function.

object(arg1, arg2....)
# => ...results...


def sayname = fn(name){

Here we define the function "sayname ()". In this case, you can use the function "println ()" to print the contents of the "name" field.

#=> "Oytun"

As you can see, simply called the name "println()" function has worked.