klyn.math.NDArray.operator[]
method
public operator[](i as Long) as Object
Description

Gets one scalar for a 1D array, or an independent first-axis slice for higher ranks. The result is Object because array rank is a runtime value. Use an explicit slice such as matrix[0, :] for a statically typed tensor.

Parameters
ParameterDescription
iFirst-axis coordinate; negative indices count backwards.
Returns

T for a vector; NDArray<T> for a higher-rank array.

Throws
  • IndexException for an out-of-range coordinate.
Example
a = NDArray<Int>([10, 20, 30])
print(a[1])   # 20