“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay who are based in Denmark...”

Rob Lacey
Senior Software Engineer, UK

Elixir: what is a cat?

I like cats, but what are they made of?

Robs-iMac:hello roblacey$ iex
Erlang/OTP 21 [erts-10.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Interactive Elixir (1.7.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> 'cat'
'cat'
iex(2)> Enum.to_list 'cat'
'cat'
iex(3)> [head | tail] = 'cat'
'cat'
iex(4)> head
99
iex(5)> tail
'at'

Ok, so Single-quoted strings are really lists of characters. Double-quoted strings are not.

iex(6)> Enum.to_list "cat"   
** (Protocol.UndefinedError) protocol Enumerable not implemented for "cat"
    (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir) lib/enum.ex:141: Enumerable.reduce/3
    (elixir) lib/enum.ex:2979: Enum.reverse/1
    (elixir) lib/enum.ex:2613: Enum.to_list/1