ListLowerExtensions<T> extension

List ops: swap, reverse copy, insert/replace at index, safe get, default if empty. Roadmap #235-241, 396-399.

on

Methods

firstOrCompute(T compute()) → T

Available on List<T>, provided by the ListLowerExtensions extension

First element, or result of compute if empty.
getOrNull(int index) → T?

Available on List<T>, provided by the ListLowerExtensions extension

Element at index, or null if out of range.
insertAt(int index, T value) List<T>

Available on List<T>, provided by the ListLowerExtensions extension

New list with value inserted at index (clamped to 0..length).
orDefault(List<T> defaultValue) List<T>

Available on List<T>, provided by the ListLowerExtensions extension

This list, or defaultValue if empty.
replaceAt(int index, T value) List<T>

Available on List<T>, provided by the ListLowerExtensions extension

New list with element at index replaced by value; no-op if index out of range.
reversedCopy() List<T>

Available on List<T>, provided by the ListLowerExtensions extension

New list with elements in reverse order.
swapAt(int i, int j) List<T>

Available on List<T>, provided by the ListLowerExtensions extension

New list with elements at i and j swapped; in range only.