1 // examples of the basic syntax
3 pi = 3.14159 // numbers are always doubles
5 greeting = "Hello World!" // string
7 square = func(x) { // functions are first class citizens
11 arr = [pi, greeting, nil] // array types
12 arr[2] = square //replace the nil element (indices start at 0)
14 length = size(arr) // use the size operator to find an arrays length
16 // tables are associative containers that can use any object as key
22 table.e = 2.71 // equivalent to table["e"] = 2.71
23 table.bar = func() { print(this.e, "\n") }
26 // flow control uses C style
28 print("pi is greater than 2\n")
30 print("pi is less or equal 2\n")
35 print(x = square(x) ", ")
39 //no ++ or -- operators
40 for(i = 0;i<size(arr);i+=1) {
51 // for each on tables has no specific order
57 // iterate over key value pairs
58 for(key, value : table) {
59 print(key " = " value ", ")