Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

Why can I write a = 3 (badmatch)?

badmatch write
0
10 Posted

Why can I write a = 3 (badmatch)?

0

In Erlang, all variables must start with a capital letter, so you can write A = 3. but not a = 3. In the latter case Erlang complains that this is a “bad match”. In the second version, the ‘a’ is an atom while 3 is a number. ‘a’ cannot be pattern matched with 3. The use of capital letters for variables comes from Prolog. If the terms atom and pattern match are new to you, have a read of the first chapter or two of the Erlang book. (Very roughly, an atom corresponds to an enum in C and pattern matching in this case is like an assert statement.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123