Printing to the Console with Elixir

Essential Elixir : part 8 of 10 published on Sep 23, 2015

Coming from Ruby, printing to console was often the fast & easy way to debug a problem.

Print to console

This is how we printed to the console in Ruby:

puts "Hello World"

With Elixir we use the IO module and the IO.puts/1 function:

IO.puts "Hello World"


In Ruby, we can inspect (see the details) of an object with:


With Elixir we can use the inspect function:

inspect some_object

Print + Inspect

Ruby has an awesome shortcut to print to console and inspect the object:

p some_object

Elixir has a similar shortcut with the IO.inspect/1 function:

IO.inspect some_object
Next: The many different ways to key Elixir Maps