Skip to content

Instantly share code, notes, and snippets.

@jayrhynas
Created July 17, 2018 20:38
Show Gist options
  • Save jayrhynas/c4dfbd58661885d482ea8239569cbb90 to your computer and use it in GitHub Desktop.
Save jayrhynas/c4dfbd58661885d482ea8239569cbb90 to your computer and use it in GitHub Desktop.
enum Planet: Int {
case mercury, venus, earth, mars, jupiter, saturn, uranus, neptune
}
struct PlanetOptions {
let planets: Set<Planet>
private init(_ planets: Set<Planet>) {
self.planets = planets
}
static let gasGiants = PlanetOptions([.jupiter, .saturn])
static let rockyPlants = PlanetOptions([.mercury, .venus, .earth, .mars])
}
func myAPIMethod(filter: PlanetOptions) {
print("call api with filter: \(filter.planets)")
}
myAPIMethod(filter: .rockyPlants)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment