Search code examples
erlangsyntax-errorreserved-words

Why I am getting this syntax error on making an atom "band"?


1> Band = band.
* 1: syntax error before: 'band'

I am trying to make an atom here, but I am getting a syntax error. Why?


Solution

  • It is not clear from the compiler error but you are getting but this due to the fact that you are using a reserved word. There is a complete list here.

    after and andalso band begin bnot bor bsl bsr bxor case catch cond div end fun if let not of or orelse query receive rem try when xor

    band is an operator for "binary and".

    You can use single quotes for atoms that can't be used directly.

    1> Band = 'band'.
    'band'