-
-
Notifications
You must be signed in to change notification settings - Fork 1
Syntax Overview
Millo Brennan-Evers edited this page Jan 21, 2020
·
7 revisions
Printing to console:
// This prints 'Hello World'
echo("Hello World")
// This uses data from the Person class and prints 'Hello! My name is David and I am 20 years old.'
echo("Hello! My name is "&Person.Name&" and I am "&Person.Age&" years old.)
// This prints 4.
echo(2+2)
echo(2*2)
Comments:
// This is a comment!
Variables:
// Variables can be defined with a colon or an equals sign.
var age = 20
var name = "David"
// This is a constant which means the value cannot be changed later on.
const weight = 90
// This is a local. It is a variable which means that is exists in a function, class, conditional or protocol only and can only be accessed from said interface.
local index = index++
Classes:
// This class uses already defined variables for class information. You do not need to use variables for classes.
class Person:
def Name = name
def Age = age
end
This can allow you to access Person.Name and Person.Age.
if Person.Age != age:
Person.Age = age
else:
Person.Age = Person.Age - age
end
Conditionals
if Person.Age > 18:
echo("This person is an adult!")
else:
echo("This person is not an adult.")
end
Functions
// This is a function for squaring a number (multiplying it by itself) then displaying it.
fn square(x):
x = (x*x)
echo(x)
end
// This is a function for squaring a number and returning it, instead of displaying it.
fn square(x):
x = (x*x)
echo(x)
local result = x
end
var result = square(result)
Arrays
arr numbers = [1, 2, 3, 4, 5]