Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get raw value in enum?

Tags:

swift

I have an enum like this one:

enum dayofweeks:Int { Mon = 1, Tu, We, Th,Fr, Sa, Su }

how to can get raw value of Sa ?

I only know the opposite way:

dayofweeks.Int(RawValue, 6) = Sa
like image 229
Nguyen Diep Avatar asked Jan 19 '26 02:01

Nguyen Diep


1 Answers

Here:

dayofweeks.Sa.rawValue

Also, why is your capitalization is reversed? Type name should begin with Capital letter, not case name.

And you forgot case keyword in enum declaration.

like image 74
user28434'mstep Avatar answered Jan 20 '26 20:01

user28434'mstep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!