Created
July 6, 2019 21:30
-
-
Save AviTsadok/bad97d9e6ad9a28a874ca7eadda23ca3 to your computer and use it in GitHub Desktop.
Example for creating optionSet
This file contains 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
struct PizzaToppings: OptionSet { | |
let rawValue: Int | |
static let olives = PizzaToppings(rawValue: 1 << 0) | |
static let pinApple = PizzaToppings(rawValue: 1 << 1) | |
static let mushrooms = PizzaToppings(rawValue: 1 << 2) | |
static let sausage = PizzaToppings(rawValue: 1 << 3) | |
static let bacon = PizzaToppings(rawValue: 1 << 4) | |
static let extraCheese = PizzaToppings(rawValue: 1 << 5) | |
static let blackOlives = PizzaToppings(rawValue: 1 << 6) | |
static let greenPeppers = PizzaToppings(rawValue: 1 << 7) | |
static let spinach = PizzaToppings(rawValue: 1 << 8) | |
static let mozzarella = PizzaToppings(rawValue: 1 << 9) | |
static let garlic = PizzaToppings(rawValue: 1 << 10) | |
static let meatLovers: PizzaToppings = [.bacon] | |
static let hawaiian: PizzaToppings = [.pinApple, .bacon] | |
static let avi_toppings : PizzaToppings = [.olives ,.mushrooms ,.extraCheese] | |
static let all: PizzaToppings = [ | |
.olives, .pinApple, .mushrooms, .sausage, .bacon ,.extraCheese ,.blackOlives ,.greenPeppers ,.spinach ,.mozzarella ,.garlic] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment