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

Popular posts from this blog

Enums with associated values in swift

Enum raw value