+/TECS

git clone https://git.julia.blue/+/TECS

P1n3appl3Finish and test Math2a59f11

v1.0
644 B24 linesraw
1/**
2 * Represents an array.
3 * In the Jack language, arrays are instances of the Array class.
4 * Once declared, the array entries can be accessed using the usual
5 * syntax arr[i]. Each array entry can hold a primitive data type as
6 * well as any object type. Different array entries can have different
7 * data types.
8 */
9class Array {
10
11    /** Constructs a new Array of the given size. */
12    function Array new(int size) {
13        if(size < 0){
14            do Sys.error(2);
15        }
16        return Memory.alloc(size);
17    }
18
19    /** Disposes this array. */
20    method void dispose() {
21        do Memory.deAlloc(this);
22        return;
23    }
24}