Skip to content

Instantly share code, notes, and snippets.

@akingdom
Last active March 25, 2022 14:25
Show Gist options
  • Save akingdom/71142b05197bd364cf28e61c096aba5b to your computer and use it in GitHub Desktop.
Save akingdom/71142b05197bd364cf28e61c096aba5b to your computer and use it in GitHub Desktop.
enum tricks in Swift
// 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