ビットフラグ
ビットフラグはOpsionSetを定義すると使える。
struct Hoge : OptionSet { let rawValue : Int static let a = Hoge(rawValue: 0b0001) static let b = Hoge(rawValue: 0b0010) static let c = Hoge(rawValue: 0b0100) static let all:Hoge = [.a, .b, .c] static let ab:Hoge = all.subtracting(.c) func isNonEmpty() -> Bool { return !self.isEmpty } func isIntersect(_ v:Hoge) -> Bool { return self.intersection(v).isNonEmpty() } }