copy method

NdArray copy()

Returns a copy of this array.

The copy is a deep copy. This means you are creating a new NdArray that is identical to this one. Any modifications to one does not affect the other.

Note: A non-primitive data types that use references (like custom objects) might not create new versions of themselves when copied. If this is the case, changes to one of those objects will appear in both NdArrays.

Implementation

NdArray copy() {
  final List<dynamic> copy = _copy(_data);

  return NdArray(numDimensions).._data = copy;
}