Difference between Force Unwrapping Optionals and Implicitly Unwrapped Optionals

前端 未结 4 1986
既然无缘
既然无缘 2020-12-13 05:22

I was very confused about forced unwrapping and implicit unwrapping at first. Now, the following understanding comes from my self-study:

There is no

4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-13 05:29

    I'd say no, you're drawing a false distinction:

    • The first half is right; unwrapping is certainly something you do to Optionals, and forced unwrapping is a way to do it (an unsafe way).

    • But as to what an implicitly unwrapped Optional is: it is a way of marking an Optional type so that forced unwrapping will be done for you (if you use the Optional in a place where it can't be used, but could be used if it were unwrapped).

提交回复
热议问题