I was wondering if there is a Swift equivalent of Java's Enum.ordinal()
method.
You can use rawValue
to access the ordinal value of an enum marked with Int
.
enum SomeEnum: Int {
case first
case second
case third
case fourth
}
print(SomeEnum.third.rawValue) //2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With