Chapter 2. A whirlwind tour

 

This chapter covers

  • Your first Elixir program
  • Using Interactive Elixir (iex)
  • Data types
  • Pattern matching
  • List and recursion
  • Modules and functions
  • The pipe (|>) operator
  • Erlang interoperability

Instead of discussing each Elixir language feature in depth, I’m going to present them as a series of examples. I’ll elaborate more when we come to concepts that may seem unfamiliar to, say, a Java or Ruby programmer. For certain concepts, you can probably draw parallels from whatever languages you already know. The examples will be progressively more fun and will highlight almost everything you need to understand the Elixir code in this book.

2.1. Setting up your environment

Elixir is supported by most of the major editors, such as Vim, Emacs, Spacemacs, Atom, IntelliJ, and Visual Studio, to name a few. The aptly named Alchemist (https://github.com/tonini/alchemist.el), the Elixir tooling integration that works with Emacs/Spacemacs, provides an excellent developer experience. It features things like documentation lookup, smart code completion, integration with iex and mix, and a ton of other useful features. It’s by far the most supported and feature-rich of the editor integrations. Get your terminal and editor ready, because the whirlwind tour begins now.

2.2. First steps

2.3. Data types

2.4. Guards

2.5. Pattern matching

2.6. Lists

2.7. Meet |>, the pipe operator

2.8. Erlang interoperability

2.9. Exercises

2.10. Summary

sitemap