SE-0217 - The "Unwrap or Die" operator

Introducing the Never-rhs variant of !! allows you to:

  • Retain unsafe semantics with !! over ??. Limiting the rhs to Never ensures that any non-nil value will always have a non-returning outcome.
  • Preserve the context information without extra compiler work (#file, #function, #line)
  • Allow the rhs use of the universal-error scenarios discussed in this thread and proposal: Introducing Namespacing for Common Swift Error Scenarios - #22 by davedelong, also allowing the rhs extension to instances of the FatalReason, which has been designed for expansion to specific use scenarios:
wrappedURL !! fatalError(reason: .unconstructableURL)
1 Like