resize

fun <T> MutableList<T>.resize(size: Int, defaultValue: T)

Resizes the mutable list to the specified size. If the new size is greater than the current size, the list is expanded and the new elements are initialized to the specified default value. If the new size is less than the current size, the list is truncated.

Parameters

size

The target size for the list.

defaultValue

The value to use for initializing new elements if the list needs to be expanded.