class

IndexError

Inherits Exception / Reference / Object

Raised when the given index is invalid.

a = [:foo, :bar]
a[2] # raises IndexError