Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's a small thing but I think let/var deserved a mention too (my C code is littered with const everywhere).


He did say he was going to write a series of articles about Swift. Give him time. :-)

The main "aha" point of this article for me was the way optional values eliminate a whole class of programming errors that are pervasive in the "C family" of languages, and does so in a rather elegant way. (Apparently Scala has a similar capability, but I'm not familiar with Scala.)


Scala, Ocaml, SML, Haskell, Swift, C# (the Nullable type) and many other languages have Optionals/Maybes/Nullable types (all names for the same thing).

I agree Optional's should booster safety (in the iOS/OS X world) if Swift can convince everyone to start using them.


People are probably most familiar with them, I think, in the form of Haskell's Maybe monad. (Though that has the extra feature of black-holing computations that try to operate on Nothing.)


Swift has the "black-holing" as well in the form of either explicitly calling Optional's map method, or the syntactic sugar: myTypeTOpt?.methodOnTypeT()


> People are probably most familiar with them, I think, in the form of Haskell's Maybe monad.

Or just simply "Maybe" ;)

https://groups.google.com/forum/#!topic/elm-discuss/1acyOfxv...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: