강의

멘토링

커뮤니티

Inflearn Community Q&A

mrke078120's profile image
mrke078120

asked

Learn iPhone App Development by Creating 12 Apps for iOS9 & Swift2

120. Weather App - JSON Parsing 5

형변환 할 때 사용하는 as!와 as?의 차이점이 무엇인가요?

Written on

·

354

0

제가 optional value, unwrapping을 이해할 때에 헷갈리는 부분이 있어서 그런 것인지 as!와 as?의 차이점이 잘 와닿지 않는 것 같습니다. 혹시 좀 정리해주실 수 있나요?
swiftios

Answer 2

0

SwiftLearner님의 프로필 이미지
SwiftLearner
Questioner

감사합니다! 강의 듣다보니 바로 다음 강에 나오더라고요 ㅎ 답변 감사드립니다. 좀 더 확실히 알게된 것 같습니다. 

0

appstamp70006님의 프로필 이미지
appstamp70006
Instructor

as?는 optional value 그대로 형변환 하는거구요.
as!는 unwrapping 하면서 형변환 하는 겁니다. iBook 에 나오면 내용은 아래와 같습니다.   The conditional form, as?, returns an optional value of the type you are trying to downcast to. The forced form, as!, attmpts the downcast and force-unwraps the result as a single compound action.
mrke078120's profile image
mrke078120

asked

Ask a question