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

Alex Blewitt alex.blewitt at gmail.com
Fri Dec 4 09:57:52 CST 2015


> On 4 Dec 2015, at 16:44, Amir Michail <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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151204/48445dda/attachment.html>


More information about the swift-evolution mailing list