Enums in swift
Traditionaly enumerations are used to represent a type that can take definite values.
Eg
enum Gender {
case male
case female
case others
}
let genderOfPerson = Gender.male
Using gender in switch statement
switch genderOfPerson {
case .male:{
print("Male is the gender")
}
case .female:{
print("Female is the gender")
}
case .others:{
print("others is the gender")
}
}
Comments
Post a Comment