Skip to content

Instantly share code, notes, and snippets.

@Reflejo
Last active August 29, 2015 14:13
Show Gist options
  • Save Reflejo/59c6e18532b6ba5f6d45 to your computer and use it in GitHub Desktop.
Save Reflejo/59c6e18532b6ba5f6d45 to your computer and use it in GitHub Desktop.
Simplified version
#!/usr/bin/env xcrun swift -O
struct MyOptions: RawOptionSetType, BooleanType {
var boolValue: Bool { return self.rawValue != 0 }
var rawValue: UInt
init(rawValue value: UInt) {
self.rawValue = value
}
init(nilLiteral: Void) {
self.rawValue = 0
}
static let allZeros = MyOptions(rawValue: 0)
static let OptionA = MyOptions(rawValue: 0b10)
static let OptionB = MyOptions(rawValue: 0b100)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment