Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elixir - atom which doesnt start with upper case

Tags:

erlang

elixir

In elixir, atoms should start with :, so why even all literals which starts with upper case are treated as atoms too?

IO.puts is_atom(Foo) # true, why????
IO.puts is_atom(foo) # error undefined function
IO.puts is_atom(:foo) # true
like image 262
Krab Avatar asked Jul 22 '14 08:07

Krab


1 Answers

As you can see here, identifiers that start with uppercase letters are treated as atom aliases. In your case, Foo is an alias of :'Elixir.Foo' which is an atom.

like image 116
Nicd Avatar answered Oct 13 '22 05:10

Nicd