Next lesson playing in 5 seconds

  • Overview
  • Transcript

1.3 Installing Elixir and Using the REPL

To use Elixir, you have to first install it. I’ll show you how in this lesson, and we’ll explore the basic Elixir syntax in the interactive Elixir console.

Related Links

1.3 Installing Elixir and Using the REPL

Hi and welcome back to Get Started With Elixir. In this lesson we are going to install Elixir and use the interactive Elixir console IEX. Elixir is available for various distributions like macOS, Windows, Unix or even the Raspberry Pi. It requires at least Erlang 18, which will get installed automatically when using the recommended installation instructions. On macOS, the easiest way to install it is by using Home Brew and running brew install elixir. On Windows, you can download the provided installer. I use chocolatey with cinst alexa. I have a Mac, so I'm going this route. As you can see, erlang-19 will get installed, as well. Now that we have installed Elixir, we have access to the REPL or Read–Eval–Print Loop. It is better known as an interactive console or shell. In Elixir it is called IEX or Interactive Elixir. It works like you would expect it to. You can perform operations like 2 + 2 or assign variables like x = 3. You can also define functions like we did last lesson. The only thing to keep in mind, is that you have to surround it with a module. You will learn what that is in a later lesson. Now you can use the sum function, by referencing the main module. If you need help with something like the enum math function, just use the h keyword to get a nicely formatted documentation. If you have a type and want to know more about it, just use the i keyword. And if you wonder what other keyword functions there are, just use h without an argument. Now, when I execute a pwd helper, it gives me a warning, that I have to use parentheses. This has been added in Elixir 1.4. To enforce a clearer distinction between variables and argument list functions in your code. If you want to exit the shell just use Ctrl+C twice. This is because of the underlying Erlang virtual machine BEAM. This concludes the short introduction to the Elixir REPL. It is a very easy to use but powerful tool where you can experiment with your code. In the next lesson we're going to start with the Elixir language itself by looking at data types. See you there.

Back to the top