What is the difference between expressions and statements in Erlang?

StackOverflow https://stackoverflow.com/questions/23617399

  •  21-07-2023
  •  | 
  •  

سؤال

In Erlang, what is the difference between Expressions and Statements?

هل كانت مفيدة؟

المحلول

In Erlang, everything has a value.

So, the difference is that Erlang has expressions but does not have statements.

That explains Erlang's (arguably) wacky "if" expression.

Since it, and everything else, must evaluate to some kind of value, people often end them with a "true -> ok" clause to ensure the if doesn't crash at runtime.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top