-
Notifications
You must be signed in to change notification settings - Fork 0
Data Types
mar edited this page May 21, 2023
·
3 revisions
// Values and variables
1 # integers
"string test" # strings
true # booleans
[1, 2, 10] # arrays
{key2: val2, key1: val1} # maps
set(1,2 10, 20) # sets
var err = error("error!") # errors
var ex = 12 # variables
// this is a comment # comments
var normal = 12
var hex = 0xff
10 + 1
10 - 1
10 * 2
10 / 2
10 % 2
10 == 10
10 != 11
10 < 2
10 > 2
10 <= 2
10 >= 2
0xfe & 0x01
0xfe | 0x01
0xfe << 1
0xfe >> 1
~0xff
hex(12)
var t = true
var f = false
true && false
true || false
true == false
true != false
var s = "test string"
var s = 'test string'
s == "test string"
s != "test strings"
len(s) == 11
from_hex("FF0102") == [255, 1, 2]
var arr = [1, 2, 3]
arr[0] == 1
arr.push(4)
arr.pop()
arr.slice(0, 1)
contains(arr, 1)
var m = {"test": value, 1: 23}
len(m) == 2
m["test"] = value
m.set("new", 12)
m.pop("new")
contains(m, "test")
var s = set(1, 3, 5, 4)
var s2 = set([1, 2, 4, 3, 4])
s.add(10)
s.remove(3)
contains(s, 1)
var err = error("error!")
var div = func(x, y) {
if y == 0 {
ret err("division by zero")
}
ret x/y
}
var res = try div(1, 0)