logoalt Hacker News

_fluxyesterday at 1:22 PM1 replyview on HN

What language is this? I'd expect a language with a ? -type would not use an Optional type at all.

In languages such as OCaml, Haskell and Rust this of course works as you say.


Replies

_rendyesterday at 1:57 PM

This is Swift, where Type? is syntax sugar for Optional<Type>. Swift's Optional is a standard sum type, with a lot of syntax sugar and compiler niceties to make common cases easier and nicer to work with.

show 1 reply