Basics - qlova/ilang GitHub Wiki
Basics of i
Variables
n = 3
s = "string"
Concepts (aka Functions)
concept add(a,b) {
return a+b
}
concept printchars(s) {
for char in s
print(char)
end
}
concept hello() {
return "hello"
}
If statements
If statements take numeric values, 0 is false, anything else is true.
if expression
print("expression is true!")
else if condition
print("expression is false...")
print("but condition is true!")
else
print("expression and condition are false...")
end
Loops
The loop statement loops over the enclosed block of code an unspecified amount of times, it's up to you to break out of the loop when you need to.
loop {
if leaving
break
end
}
For Loop
The for loop is more useful as it strictly specifies how many times the loop will run.
for element in array
print(element)
if bad(element)
delete() //--This deletes the element (does not preserve order)
end
end
for value in array
print(i, ":", value)
end
for each 0 to 10
print(i)
end
for each in array
print(i)
end
Errors
The errors block will run if there has been an error.
n = number("abc")
errors {
print("Could not convert abc to a number!")
}