Skip to content
brett hartshorn edited this page Jan 23, 2015 · 6 revisions

1D Array

arr = []int(1,2,3)

2D Array

[][]T(...) translates to a variable sized vector of vectors. None is allowed as a sub-vector because each sub-vector is wrapped by std::shared_ptr. Array comprehensions can be used in the constructor as sub-vectors. https://github.com/rusthon/Rusthon/blob/master/regtests/c%2B%2B/array_of_arrays.py

arr = [][]int(
	(1,2,3),
	(4,5,6,7,8),
	None,
	(x for x in range(20)),
)

Comprehension syntax can also be used like this, below a 8x4 array is constructed.

arr = [][]int( (1,2,3,4) for i in range(8) )

A function that returns a variable sized 2D vector of integers

def F() -> [][]int:
   arr = [][]int( (1,2,3), (4,5) )

2D Array of Objects

arr = [][]MyClass( ... )

https://github.com/rusthon/Rusthon/blob/master/regtests/c%2B%2B/array_of_arrays_objects.py

3D Array

TODO

Sidebar

Clone this wiki locally