Last active
March 25, 2022 14:25
-
-
Save akingdom/71142b05197bd364cf28e61c096aba5b to your computer and use it in GitHub Desktop.
enum tricks in Swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Means to provide an alias to a value | |
// in a similar manner to Objective-C | |
// since Swift does not permit duplicate raw values | |
// | |
// By Andrew Kingdom | |
// MIT license | |
enum SomeOption : Int | |
{ | |
case First = 0 | |
case Second | |
case Third | |
static let Default = SomeOption.Second // (non-standard default value) | |
} | |
class MyClass { | |
let someOption = SomeOption.Default | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment