-
Notifications
You must be signed in to change notification settings - Fork 5
Array Operators
Michael Wang edited this page Feb 4, 2022
·
2 revisions
There are two principle operators in regards to arrays: Getting an index, a binary operator; and setting an index, a ternary operator. Most operators in SuperForth are very C-like.
To access an array's length, use the #
operator. It's a unary operator that takes an array operand, and returns it's length as an integer;
array<int> array = new int[23];
int len = #array; //is 23
To access an array's elements, place the array value followed by the index value encapsulated in brackets. The following example demonstrates getting an index from an array.
array<int> array = range(1, 100, 2);
int i = 0;
while(i < #array) {
int access = array[i];
}
To set an array, place the arrays value followed by the index value encapsulated in brackets then a set token followed by a the value you want to set with.
- Getting Started
- The Language and Syntax
- Type Declarations
- Primitive Values
- Collection/Object Values
- Operators
-
The Standard Library
- More docs coming soon after APs.
- FFI and Interoperability
- The Implementation