[swift-evolution] Guard Implicit Fallback

Jessy Catterwaul mr.jessy at gmail.com
Thu Feb 11 12:11:06 CST 2016


The first related thought I had was answered by Chris Lattner:

https://forums.developer.apple.com/thread/4857

Does this proposal represent “code clarity”? Yes, I think so. Either guard must be paired with an “else”, or the else clause is the obvious, which is normally a return:

func ƒ<A, B, C>(a: A?, b: B?, c: C?) {
   guard let a = a, b = b, c = c else {return}
}

This is better:
guard let a, b, c

But what should it be in a loop? break? continue? I don’t think return would be appropriate. Not that I escape loops very often anymore; return is obvious for “forEach”, because it can’t “continue” or “break”.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160211/525bca1f/attachment.html>


More information about the swift-evolution mailing list