byOrdinalOrDefault

inline fun <T : Enum<T>> Enum.Companion.byOrdinalOrDefault(ordinal: Int, defaultValue: T): T

Returns the enum by matching ordinals position, or the given default value if no ordinals match.

Return

The enum value matching the ordinal, or the default.

Parameters

ordinal

The ordinal value in this enum

defaultValue

The default value to return if the ordinal is out of range