optional
[Swift] Swift 공식문서 정리 - 5(옵셔널 체이닝)
옵셔널이란? 옵셔널이란 nil을 사용할 수 있는 Type을 옵셔널 타입이라고 부르며, nil을 가질 수 있는 값은 옵셔널 타입이다. 옵셔널 체이닝(Optional Chaining) class Person { var residence: Residence? } if let roomCount = john.residence?.numberOfRooms { print("John's residence has \(roomCount) room(s).") } else { print("Unable to retrieve the number of rooms.") } // Prints "Unable to retrieve the number of rooms." 강제 언래핑(Forced Wrapping) var name: Strin..