Skip to content

Instantly share code, notes, and snippets.

@polac24
Created August 26, 2017 18:52
Show Gist options
  • Save polac24/75e3e17da8627cffd1f6890f0f94399b to your computer and use it in GitHub Desktop.
Save polac24/75e3e17da8627cffd1f6890f0f94399b to your computer and use it in GitHub Desktop.
enum BestEnum:BestEnumRaw{
static var all:Set<String> = []
case myCase = "my_case"
case otherCase = "otherCase"
}
// ensuring that all static var fills with raw values
BestEnum(rawValue: BestEnumRaw())
// Set<String>
let allCasesStrings = BestEnum.all
// Array<BestEnum>
let allCases = BestEnum.all.map({BestEnumRaw(stringLiteral: $0)}).flatMap(BestEnum.init)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment