[swift-evolution] [Idea] if let value!

Daniel Höpfl daniel at hoepfl.de
Wed May 18 03:21:12 CDT 2016


Just an idea: Why don’t we think about it similar to try?

var anOptional : String?

let? anOptional { /* use it, but cannot change it */ }
let! anOptional { /* use it, without checking, cannot change it */ }

var? anOptional { /* use it, can also change it, */ }
var! anOptional { /* use it, without checking, can also change it */ }

Is it allowed to set it to nil in the var case? Hard to say.

On 17.05.16 15:43, Vladimir.S via swift-evolution wrote:
> It is common to shadow optional value name with unwrapped value with
> same name:
> 
> if let someGoodValue = someGoodValue {...}
> 
> What if we'll have a syntax to not repeat the variable name to achieve
> the same target:
> 
> if let someGoodValue! {...}
> 
> What do you think?
> _______________________________________________
> 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