Chapter 17Protocols in Swift vs. Ruby and Elixir

by José Valim

When Apple announced its new language, Swift, I started reading the docs and playing with the language with great curiosity. I was pleasantly surprised with many features in Swift, like the handling of optional values (and types) and the immutability being promoted throughout the language.

The language also feels extensible. For extensibility, I am using the same criteria we use for Elixir, which is the ability to implement language constructs using the language itself.

For example, in many languages, the short-circuiting && operator is defined as a special part of the language. In those languages, you can’t reimplement the operator using the constructs provided by the language. ...

Get Functional Programming: A PragPub Anthology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.