enforceValidIndex

fun <T> List<T>.enforceValidIndex(index: Int)

Make sure an index is valid for this List.

Doing all checks with the same function and error message is probably easier to debug than letting an array access fail at the point of access.

Parameters

index

Index to check.

Throws

If given invalid index.

Sources

jvm source
Link copied to clipboard