arrayTruncateLast function Null safety

Array arrayTruncateLast(
  1. Array a
)

Return a Array without the last element

Examples

var n = Array([1, 2, 3]);

print(arrayTruncateLast(n));

/* output:
Array([1.0, 2.0])
*/

Implementation

Array arrayTruncateLast(Array a) {
  var c = Array.fixed(a.length - 1);
  for (var i = 0; i < c.length; i++) {
    c[i] = a[i];
  }
  return c;
}