insertBetween method

List<E> insertBetween(
  1. E value
)

在数组之间插入元素

Implementation

List<E> insertBetween(E value) {
  if (isEmpty) return this;

  List<E> newList = [];
  for (int i = 0; i < length; i++) {
    newList.add(this[i]);
    if (i < length - 1) newList.add(value);
  }

  return newList;
}