Elixir - an atom that does not start with an uppercase

In an elixir, atoms must begin with : so why even all literals that begin with an uppercase are also treated as atoms?

 IO.puts is_atom(Foo) # true, why???? IO.puts is_atom(foo) # error undefined function IO.puts is_atom(:foo) # true 
+6
source share
1 answer

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

+11
source

Source: https://habr.com/ru/post/972642/


All Articles