[swift-evolution] guard let x = x

William Sumner prestonsumner at me.com
Mon Oct 31 14:25:59 CDT 2016



> On Oct 31, 2016, at 1:22 PM, William Sumner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Oct 31, 2016, at 1:11 PM, Kenny Leung via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> OK then, how about an extension to the proposal that says “guard variable always implies guard unwrap variable when the only thing present in the guard clause is an optional or list of optionals”?
>> 
>> So you could write
>> 
>> guard foo else {
>> }
>> 
>> guard foo, bar else {
>> }
>> 
>> -Kenny
> 
> 
> That would enable some strange-looking code:
> 
> var foo: Bool?
> guard foo, foo else {}
> 
> Preston
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

I missed the part where you require only optionals in the clause. However, I still don’t like the visual ambiguity between testing boolean expressions and unwrapping optionals.

Preston


More information about the swift-evolution mailing list