Answer the question
In order to leave comments, you need to log in
How to work with enum in swift?
Good morning.
I'm just learning swift and so far I can't really understand how to work with enum.
Let's say you need to make Makes and Models of cars, this is just an example, I want to understand how to work with it. It turns out that we have the data in the form of a tree, it should not turn out "Mercedes Camry"
enum Toyota: String {
case Camry = "Camry",
Avensis = "Avensis",
Corolla = "Corolla",
Avalon = "Avalon"
}
enum Mercedes: String {
case S_600 = "S 600",
G_65_AMG = "G 65 AMG",
C_63_AMG = "C 63 AMG"
}
enum Volkswagen: String {
case Passat = "Passat",
Golf = "Golf",
Touareg = "Touareg",
Polo = "Polo",
Vento = "Vento",
Jetta = "Jetta"
}
enum MM { //: ?
case Toyota
case Mercedes
case Volkswagen
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question