-
Notifications
You must be signed in to change notification settings - Fork 1
Basics
Splizard edited this page Oct 28, 2016
·
12 revisions
##Variables Variables can be created with the "var" keyword, just a warning: NO DECIMAL NUMBERS.
var n = 3
var s = "string"
If statements take numeric values, 0 is false, anything else is true.
if expression
print("expression is true!")
elseif condition
print("expression is false...")
print("but condition is true!")
else
print("expression and condition are false...")
end
##Switch statements Switched in I are syntactic sugar for if-else chains. They are not faster (yet). Only numeric values are supported.
switch expression {
case 0
print("expression is zero")
case 1
print("expression is one")
default
print("expression is not one or zero")
}
##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 id, value in array
print(id, ":", element)
end
for n over [0, 10]
print(n)
end
for id over array
print(id)
end
The issues block will run if there has been an error, the explanation mark is used to clear the status of any previous errors and that we are interested in future errors.
!var n = number("abc")
issues {
print("Could not convert abc to a number!")
}