Swift null safety questions


#1

The explicit-at-definition, implicit-at-call-site force unwrapping of optionals can be achieved with this syntax:

func test(name1: String!, name2: String!) {
  print(name, name2)
}

// prints 'first second' - does not print 'Optional("second")'
test(name1: "first", name2: Optional("second"))

I think this is about as ergonomic as possible.

I agree with Austin that a force-unwrap error should be fatal. There is sufficient syntax in the language to allow the safe handling of optionals that we don't need to make the unsafe handling of optionals safe as well. You have the opportunity to "catch" a nil value with an if-let or a guard-else; I don't see a compelling reason to allow the catching of errors arising from circumventing those constructs.