enum Laptop {
// associate value
case name(String)
...
}
enum Laptop {
// associate string value
case name(String)
// associate integer value
case price (Int)
}
// pass string value to name
var brand = Laptop.name("Razer")
print(brand)
// pass integer value to price
var offer = Laptop.price(1599)
print(offer)
enum Distance {
// associate value
case km(String)
...
}
enum Distance {
// associate value
case km(String)
case miles(String)
}
// pass string value to km
var dist1 = Distance.km("Metric System")
print(dist1)
// pass string value to miles
var dist2 = Distance.miles("Imperial System")
print(dist2)