Tips, tricks, and code samples covering common tasks in Elixir.
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.
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.
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.
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.
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.
Concat Lists with Elixir
How to concat 2 lists with Elixir.
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.
Printing to the Console with Elixir
How to output to console for simple ad-hoc debugging in Elixir.
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.
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.