Link
Notice
목록자료형 체크 (1)
HIT해

Swift에서 자료형을 체크하는 방법을 알아보려한다.if isguard isswitch case isif case isguard case is if isclass Cat {}class Dog {}let myCat = Cat()if myCat is Cat { print("고양이입니다")} guard is func checkIfIsCat(){ guard myCat is Dog else { print("고양이가 아닙니다") return } print("고양이입니다.")}checkIfIsCat() // 고양이가 아닙니다 switch case isswitch myCat {case is Dog: print("강아지입니다.") // 자료형 명을 변경해서 확인..
Swift/기초문법
2024. 8. 19. 21:52