[swift-evolution] Allow let binding of non-optionals

H2CO3 h2co3 at h2co3.org
Thu Jan 7 02:08:04 CST 2016


+1 to that. It's really useful; I think optional binding is a special case of the more general notion of "bind and check as Boolean", which is a pattern that comes up everywhere. It's really more convenient than having to declare another variable in the outer scope (cluttering it).

Sent from my iPad

On 2016. jan. 7., at 7:40, Russ Bishop <xenadu at gmail.com> wrote:

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


More information about the swift-evolution mailing list