Primitives
Listed below are all the different types that Loop has out of the box. All the types have an explanations and some examples.
Integer
An integer is a primitive value that can be up to 64bits in length. You can define an integer like this:
Methods
Convert to string
Booleans
A boolean is a primitive value that can either be true or false. You can define a boolean like this:
Methods
Convert to integer
This method will cause an exception if the string is unable to be converted.
true = 1
false = 0
Strings
A string is a sequence of characters inside "
's. You can define a string like this:
Methods
Convert to integer
This method will cause an exception if the string is unable to be converted.
Null
Loop only has one primitive indicating the absence of a value. Which is "null", a Null value indicates "not a value". You can define something to be null like this:
The Null primitive will result in "false", for example.
Arrays
An array is a list of values. Arrays are automatically dynamic but can only have one type in them.
Accessing Arrays
Accessing an array is simple. You use the index operators (square brackets []). Let's take the previous example and use it here to access the "100" value in the sub array.
Or a simpler array:
Methods
array.add(element1, element2, ...)
array.remove(index: Integer)
array.length()
Hashmaps
A hashmap is a way to bind keys to values. The key is limited in what types they can be, currently these types are allowed as keys:
String
Integer
Boolean
Hashmap keys are required to be unique, they can have spaces as well (if you're using a string as key).
Creating a hashmap is easy and might seem familiar if you've used other languages before. An example with a few sample key value pairs is as follows:
Important: the key and value types can only be specified once, and require to be the same afterwards.
Last updated