[swift-evolution] Proposal: Add implicit/default else-behaviour for the guard statement

Gwendal Roué gwendal.roue at gmail.com
Thu Dec 17 05:01:43 CST 2015

> Le 17 déc. 2015 à 11:58, Andrey Tarantsov via swift-evolution <swift-evolution at swift.org> a écrit :
> 4) I would love a “guard!” variant that crashes instead of returning.

Isn’t it the role of assert and precondition?

Yet I have to admit that assert and precondition can not replace guards like the following, which define a variable:

	guard let x = optionalX else {
	    fatalError("Missing x")
	// use x

Gwendal Roué

More information about the swift-evolution mailing list