Skip to content
This repository was archived by the owner on Oct 23, 2018. It is now read-only.
dangreen edited this page Jan 2, 2015 · 2 revisions

Most of array features were taken from CoffeeScript:

Array arr = [0..9];      // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
// same as
Array arr = [0...10];
	
arr[0..2] = [584, 404];  // [584, 404, 3, 4, 5, 6, 7, 8, 9]
console.log(arr[0..2]);  // [584, 404, 3]

one feature was taken from PHP:

arr[] = 22;              // [584, 404, 3, 4, 5, 6, 7, 8, 9, 22]

absolutely new features are last element access:

console.log(arr[]);      // 22 

and negate accessor (only for static negate index):

arr[-1]; // last element
arr[-2]; // pre-last element

for other cases you can use % unary prefix:

int index = -10;
arr[%index] = 34; // arr[index %% arr.length];
Clone this wiki locally