[swift-evolution] allowing to specify optionality with type inference

Erica Sadun erica at ericasadun.com
Thu Mar 31 09:21:35 CDT 2016


> On Mar 24, 2016, at 4:22 AM, Hugues Bernet-Rollande via swift-evolution <swift-evolution at swift.org> wrote:
> ```
> var a:String? = String()
> // or
> var b = String() as String?
> // or
> var c:Optional<String> = String()
> ```

When I need to force an optional (primarily for sample code) I can do this already:

```
var myOptionalString = Optional("")
```

In this example, `myOptionalString ` picks up the type as well as the optionality.
Does this not meet your requirement of "Allowing to specify only the optionality part of 
a variable type while still having the actual wrapped type infered by the assignement" in existing
Swift?

Beyond that, can you offer any compelling use-cases that motivate this change?

-- E


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160331/ac8a9d7d/attachment.html>


More information about the swift-evolution mailing list