[swift-evolution] mandatory "?" suffix for identifiers associated with optional types

Amir Michail a.michail at me.com
Fri Dec 4 10:17:18 CST 2015


> On Dec 4, 2015, at 10:57 AM, Alex Blewitt <alex.blewitt at gmail.com> wrote:
> 
> 
>> On 4 Dec 2015, at 16:44, Amir Michail <a.michail at me.com <mailto:a.michail at me.com>> wrote:
>> 
>> I don’t want to remember if a variable is optional. I want to see it in the variable name.
> 
> Optionality is associated with the type, not the identifier. In addition, how would you deal with type aliases to optional constructs?
> 
> typealias MaybeString = String?
> var maybe:MaybeString
> 
> This doesn’t ‘look’ like an optional value (so would it deserve a ? at the end) but if you have MaybeString? you now have an Optional<Optional<String>>. Should you have ?? there now?
> 
> Alex

You would have:

typealias MaybeString? = String?
var maybe?:MaybeString?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151204/43474a8c/attachment-0001.html>


More information about the swift-evolution mailing list