concept - expression in category elm

appears as: -expressions
Elm in Action

This is an excerpt from Manning's book Elm in Action.

  • if foo /= bar then "different" else "same" is an if-expression. Like JavaScript ternaries, if-expressions require an else branch and always evaluate to a value.
  • Just like if-expressions, case-expressions must always evaluate to a single value, meaning exactly one branch must always be chosen for evaluation. When we’re writing if-expressions, we have else to ensure that we end up with a value no matter what, whereas in case-expressions, we can use the default branch of _ -> for the same purpose.