[swift] 73. Enum CaseIterable

RudinP·2023년 10월 26일
0

Study

목록 보기
100/227

Enum CaseIterable

  • 프로토콜임
  • enum의 case들에 반복적으로 접근할 수 있도록 해줌
  • enum의 case들을 콜렉션으로 가져와줌
  • allCases
Enum Pet: String, CaseIterable{
	case cat = "고양이"
    case dog = "개"
    case bird = "새"
}

let pets = Pet.allCases
let petNames: [String] = pets.map{$0.rawValue}
profile
곰을 좋아합니다. <a href = "https://github.com/RudinP">github</a>

0개의 댓글