[swift-evolution] Allow let binding of non-optionals
Gwendal Roué
gwendal.roue at gmail.com
Thu Jan 7 12:41:20 CST 2016
+1.
`if let` does two things: 1. unwrap the optional, 2. define a new variable, scoped to the `if` statement.
Sometimes we don’t need the unwrapping, but we’d like the new, temporary, scoped variable.
Gwendal
> Le 7 janv. 2016 à 07:40, Russ Bishop via swift-evolution <swift-evolution at swift.org> a écrit :
>
> I often want to bind variables to a specific scope, or perhaps I have three optionals I want to bind and one non-optional. (Often I need that non-optional value as part of a where condition check but not being able to bind it means I leak the variable to the outer scope).
>
> Not being able to bind non-optionals breaks the flow of the code and forces me to make a minor context switch when it really doesn’t matter, nor does it aid code clarity.
>
>
> Does anyone have strong thoughts about this? I tried searching the evolution repo and the mailing list and didn’t see anything.
>
>
> —russ
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list