String
Character
"a"
Integer
64
Float (number with decimal point)
64 bit float
Boolean value (either true or false)
Array
Set
Dictionary
Addition
Unary positive, makes number positive
Subtraction
Unary negative, makes number negative
Multiplication
Division
Modulo (remainder of division)
Indice
Equals
a+=b is a=a+b
a-=b is a=a-b
a*=b is a=a*b
a/=b is a=a/b
a%=b is a=a%b
a**=b is a=a**b
a&=b is a=a&b
a|=b is a=a|b
a^=b is a=a^b
a>>>=b is a=a>>>b
a><<=b is a=a><<b
Is equal to
Has equal value and type to
Is not equal to
Doesn't have equal value or type to
Greater than
Less than
Greater than or equal to
Less than or equal to
Ternary operator; executes one of two possibilities based on boolean value
Bitwise AND
Bitwise OR
Bitwise XOR
Arithmetic shift left (shifts all the bits one space to the left, essentially multiplying it by 2)
Logical shift right (shifts all the bits one space to the right, essentially dividing it by 2)
Bitwise NOT
AND operator
OR operator
NOT operator
Returns the type of a variable
Returns true if an object is an instance of an object type
Applies method to object
Applies a state to an enum type
Denotes class of an object
Denotes instance of an object
Defines an array
Initialises an array
References an array's index
var array:[Int] = []
var array = [1,2,3]
arraylist[0]
Used to separate parameters
Used to include mutiple case options
Denotes parameters of a function
Denotes a function
Defines a block
Used for switch cases
Used for stating a variable's type
Used for stating the value of a variable in parameters
f(arg: value)
Used for denoting superclass
Used for declaring a functions return type
Declares a string
Declares a string
Concatenates strings
'These are '+'two strings!'
Hides argument label when calling a function
func add(_arg1:Int, _arg2:Int) {
Optionally declares end of a line of code
Indicates variadic number of arguments and treats them as an array
Used for variable inclusion in a string
Declares optional variable
Optional variable default value returner
Delcares non-optional variable
Declares a class (class name must have a capital letter at start)
Declares a class function
Declares a struct, like a class but no inheritance (class name must have a capital letter at start)
Used to declare constant that can't be redeclared throughout entire code
Used to declare a variable
Used to declare an object that can't be redeclared within current block
Declares an extension; which can introduce new functionality forf a type
References the class' superclass
Represents a true boolean value
Represents a false boolean value
Used for including an interface in another interface or in a class, creating polymorphism
Declares an enum; a datatype that denotes a "state" of something
enum enum {
code
}
Used for declaring an interface; like a class but has no variables and methods can be empty
Used for declaring an abstract class or method, which is a class or method that is only accessible through its subclasses and is defined in its subclass
Displays different outcomes based on the value within the expression
switch expression {
case x:
code
case y:
code
}
Delcares doubles (also known as floats, or numbers with decimal place)
Declares booleans
Declares integers
Declares strings
Declares static methods (that do not depend on the state of the class)
Throws an error object
Used for denoting methods that throw specific errors
Declares characters
Declares a method with no return value
Used for referring to the original constructor of a class on which a new object is being created
Constructor of a class (method to make objects of a class)
init() { code }
Deilitialisor function of a class (method to deinitialise objects of a class)
deinit { code }
Deilitialisor function of a class (method to deinitialise objects of a class)
Used for declaring private classes or methods, that cannot be interacted with by other classes
Used for declaring public classes or methods, that can be interacted with by other classes
Executes code on true condition
if condition {
code
}
Loops code on true condition
while condition {
//code to loop
}
repeat {
//code to loop
} while condition
Loops code for a set amount iterations or for every object in list
for item in array {
code
}
Attempts to execute code and ignores on error
try {
code
}
try (declaration) {
code;
}
Executes code at end of try statement
finally {
code;
}
Executes code on failed try statement
catch (Exception exception)
code
Executes when an if statement is false or if a try statement has no error
else {
code
}
Used for declaring case statement in a switch statement
Used for delcaring states in an enum
Imports classes or modules
import package
Used to give a final value at the end of a function or method
Used to tell compiler to end the loop
Default case in a switch statement
Used to denote a class with no subclasses or a function that can't be overwritten in a subclass
A special function within a struct that allows instances of a struct to be treated like an array where the index is a parameter and a value is returned
else {
code
}
Declares a function
func function(arglabel:arg) {
code
}
func function(arglabel:arg) -> type {
code
}
Declares a mutating function (function that changes state of a class instance)
func function(arglabel:arg) {
code
}
func function(arglabel:arg) -> type {
code
}
Declares a lambda expression
{
(arglabel:arg) -> type in
code
}
Used to tell compiler the rest of this line is not to be compiled
Opens a multi line comment
Closes a multi line comment
Encoding that uses alpha-numeric encoding as well as + and /. It uses = as padding to ensure every string has a length that is a multiple of 4
Encoding that contains numbers 0 to 9 as well as letters A, B, C, D, E, and F, that maps ASCII characters to their hex representation
Encoding that translates each letter to the letter 13 letters in front, a form of caeser cypher