Essential Elixir

Tips, tricks, and code samples covering common tasks in Elixir.

  1. Reading Values from a Tuple
    Tuples are a basic data type in Elixir. When you first encounter a tuple, you could run into some difficulties getting the data out. But don't worry, we will cover some basic, painless ways of getting the data you want out.
  2. Elixir's version of the ternary operator
    With Elixir, you don't have the ternary operator that is used in Ruby to clean up simple if/else statements.
  3. Convert int to float and float to int with Elixir
    There is no parse or convert code to change an integer to a float and vice versa. What we do have are two simple code tricks to get the job done.
  4. Looping through an array / list
    If you are writing a program, you are probably looping through an array. Here are some common ways of doing that in Elixir.
  5. Viewing all the functions in a module
    Just like you could view the methods on an object in Ruby, with Elixir you can easily view all the functions in a module.
  6. Concat Lists with Elixir
    How to concat 2 lists with Elixir.
  7. Elixir is just cool. An example with pattern matching and structs.
    Just an example from some code I wrote using Elixir. I will walk through how it works.
  8. Printing to the Console with Elixir
    How to output to console for simple ad-hoc debugging in Elixir.
  9. The many different ways to key Elixir Maps
    There are many ways to provide a key for an Elixir Map and if you don't know about the differences, it can lead to some head scratching "Why isn't this working?" moments.
  10. Piping to an anonymous function
    At some point you probably will want to use the pipe operator with an anonymous function. Here is how to do it.