checkElementIndex

open fun checkElementIndex(index: Int, size: Int)

Ensures that index specifies a valid element in an array, list or string of size size. An element index may range from zero, inclusive, to size, exclusive.

Parameters

index

a user-supplied index identifying an element of an array, list or string

size

the size of that array, list or string

Throws

if index is negative or is not less than size

if size is negative


open fun checkElementIndex(index: Int, size: Int, desc: String)

Ensures that index specifies a valid element in an array, list or string of size size. An element index may range from zero, inclusive, to size, exclusive.

Parameters

index

a user-supplied index identifying an element of an array, list or string

size

the size of that array, list or string

desc

the text to use to describe this index in an error message

Throws

if index is negative or is not less than size

if size is negative