Swift should be able to mitigate two issues related to forced unwrapping. First, it’s used as a bandaid by developers new to the language who want to make their code compile. Second, developers should be able to provide code-level annotation support for why a guaranteed wrap cannot fail and provide runtime diagnostics in any “Black Swan” scenario where they do. These items are discussed further in this proposal.
Please let me know which of the following designs you prefer. Each contains a link to a code solution. (The first item in the list (“Unwrap or Die”) links to a full proposal so scroll down to the design section.) The other two offer alternate designs. You can assume
!! can be redesigned to support both throwing and
Never solutions just as easily as
??. The proposal goes into detail as to why that was not the original design, as doing so fundamentally changes nil-coalescing semantics.
Thank you in advance for your feedback and/or participation in the survey.