Chapter 2. Intro to Elixir
This chapter covers
Now that you’ve learned a bit about the benefits Phoenix can bring to your web application development, you’ll need to know Elixir. Phoenix is a web framework that’s built on top of the Elixir language (which is built on the Erlang VM, known as BEAM). So what if you don’t know Elixir?
This chapter will get you up to speed on Elixir. If you already know Elixir, you can probably skip this chapter entirely. If you don’t know Elixir or need a refresher, this chapter will cover just enough Elixir to get you going. Some concepts won’t be covered in this chapter—I’ll teach you about them later in the book when you need to know them. I’ll also point you to more resources at the end of the chapter, in case you’d like to dive deeper into the language and all its features.
Before we begin writing Elixir, I’ll show you a quick example of what a module might look like (a module can be thought of as a collection of functions). Have you heard of the “fizz buzz” programming exercise? This is the basic idea:
- Take any series of numbers, one at a time.
- If the number is divisible by 3, print “fizz.”
- If the number is divisible by 5, print “buzz.”
- If the number is divisible by 3 and 5, print “fizzbuzz.”
- Otherwise, print the number.