-
Notifications
You must be signed in to change notification settings - Fork 0
Data Types
Each primitive type, integer, float, string, boolean, character, byte, is indicated by a name that PixMix uses for declarations.
num |
A 32-bit, signed, 2’s complement series of digits with a maximum range of 2147483647. |
float |
Follows IEEE 754-2008’s definition of a floating-point number. That is: 1 bit for the sign, 8 bits for the exponent, and 24 bits for the mantissa. |
bool |
A 1 byte value that can store either 1 or 0, or true or false. |
char |
A character is 8-bit (1 byte) data type, capable of holding one character in the local character set. |
unsigned char
num
float
To define an object, use the Object keyword followed by the name of the object. An object may be initialized during instantiation by specifying a list of its member variables and functions within curly brackets.
Object rectangle = {
num width, height
fun area() {
return width * height
}
}
Array elements are indexed beginning at position zero.
You declare an array by specifying the data type as Array
, followed by its name. The array can store multiple data types. An example declaration:
Array myArray;
You can initialize the elements in an Array
when you declare it by listing the initialized values, separated by commas, in a set of brackets. Here is an example initialization:
Array myArray = [0, “one”, 2, “three”]
You can access an element in an array by specifying the array name followed by the element index, enclosed in brackets.
myArray[1] = 1
This will assign the value 1 to the second element in the array, at position one.
Arrays can contain another array as an element, creating a multidimensional array.
Array a = [[1,2,3], [2,3,4]]
Elements will then be accessed by specifying first the index of the nested array, and second the index of the element within the nested array.
a[1][2]
Would return 4.
Made with ♥ by Nathan Burgess, Christina Charles, Edvard Eriksson, and Allie Taylor