<html><body><div>Yes, having to be explicit is the whole point about optionals: having to think about what the missing case means in the current context.<br></div><div><br data-mce-bogus="1"></div><div>-Thorsten<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div> <br>Am 11. Mai 2016 um 14:20 schrieb Patrick Smith via swift-evolution <swift-evolution@swift.org>:<br><br><div><blockquote type="cite"><div class="msg-quote"><div class="_stretch"><span class="body-text-content">I actually think this is less safe. It depends on the situation for what value the default should be. Sometimes it will be false, other times it will be true. So far better to explicitly show what the default is.<br><br><br><blockquote type="cite" class="quoted-plain-text">On 11 May 2016, at 10:16 PM, Basem Emara via swift-evolution <swift-evolution@swift.org> wrote:</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">Forcing unwrapping of optionals is bad practice, but safely unwrapping can be tedious. I’m hoping for something in between that would that would provide soft unwrapping using a syntax like: myVar?!</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">For example, currently we have to do this:</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">let temp = (myString ?? “”); print(“\(temp)”)</blockquote><blockquote type="cite" class="quoted-plain-text">if (myString ?? “”).isEmpty {…}</blockquote><blockquote type="cite" class="quoted-plain-text">if myBool ?? false {…}</blockquote><blockquote type="cite" class="quoted-plain-text">if (myInt ?? 0) > otherInt {…}</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">To something like this instead:</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">print(“\(temp?!)”)</blockquote><blockquote type="cite" class="quoted-plain-text">if myString?!.isEmpty {…}</blockquote><blockquote type="cite" class="quoted-plain-text">if myBool?! {…}</blockquote><blockquote type="cite" class="quoted-plain-text">if myInt?! > otherInt {…}</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">What this is implying is that it will attempt to unwrap or use the default of the type.</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">Of course, this will only work with primitive types and leverage their implicit default values which would go a long way with tedious code and more safety (less forced unwrapping in the world). Otherwise it will produce a compile error if doing something like: myCustomType?!. What do you think?</blockquote><blockquote type="cite" class="quoted-plain-text"><br></blockquote><blockquote type="cite" class="quoted-plain-text">Basem</blockquote><blockquote type="cite" class="quoted-plain-text">_______________________________________________</blockquote><blockquote type="cite" class="quoted-plain-text">swift-evolution mailing list</blockquote><blockquote type="cite" class="quoted-plain-text"><a href="mailto:swift-evolution@swift.org" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br data-mce-bogus="1"></blockquote><blockquote type="cite" class="quoted-plain-text"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" data-mce-href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br data-mce-bogus="1"></blockquote><br>_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" data-mce-href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" data-mce-href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></span></div></div></blockquote></div></div></body></html>