Skip to content

Instantly share code, notes, and snippets.

@AviTsadok
Created July 6, 2019 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AviTsadok/bad97d9e6ad9a28a874ca7eadda23ca3 to your computer and use it in GitHub Desktop.
Save AviTsadok/bad97d9e6ad9a28a874ca7eadda23ca3 to your computer and use it in GitHub Desktop.
Example for creating optionSet
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