replaceBy method

  1. @useResult
IList<T> replaceBy(
  1. int index,
  2. T transform(
    1. T item
    )
)

Returns a new IList, replacing the object at position index with the result of calling the function transform. This function gets the previous object at position index as a parameter.

If the index doesn't exist (negative, or out of range), will throw an error.

See also: replace.

Implementation

@useResult
IList<T> replaceBy(int index, T Function(T item) transform) {
  final T originalValue = get(index);
  final T transformed = transform(originalValue);
  return replace(index, transformed);
}