Inflearn Community Q&A
형변환 할 때 사용하는 as!와 as?의 차이점이 무엇인가요?
Written on
·
353
0
제가 optional value, unwrapping을 이해할 때에 헷갈리는 부분이 있어서 그런 것인지 as!와 as?의 차이점이 잘 와닿지 않는 것 같습니다. 혹시 좀 정리해주실 수 있나요?
swiftios
Answer 2
0
0
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.
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.





