Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4
There are several place where we use this ! 1. ! Is used to forceflully unwrapping the value of an optional variable. This should be used when we are sure that particluar optional vatiable having the value otherwise it might be unsafe as absence of value can cause the unexpecated behaviour. Application might crashed(to deal this behaviour use the optional binding or nil coalascing ). 2. To declarate the implicit optional variable. Sometimes app logic its clear that variable will have some value but we want it to be have 'nil' value some point later. Implicit optional is somewhat similar to optional variable. Its not recommended to use implicit optional until its required.
28th Aug 2016, 7:53 AM
Kamar Shad
Kamar Shad - avatar