getRangeArray method

Array getRangeArray(
  1. int start,
  2. int end, {
  3. int step = 1,
})

Return an array given an index interval

  • start : start index close interval
  • end : end index open interval

Examples

var a = Array([1,2,3,4,5]);
var b = a.getRangeArray(1, 3);

print(b);

/* output:
Array([2, 3]);
*/

Implementation

Array getRangeArray(int start, int end, {int step = 1}) {
  var b = Array.empty();
  for (var i = start; i < end; i += step) {
    b.add(this[i]);
  }
  return b;
}