Frage

It seems like the purpose of the default clause is to prevent the error from being raised if there is no pattern match. So is it fair to compare it to catching an exception (like in C#/Java), or does it serve any other purpose as well?

War es hilfreich?

Lösung

The default clause isn't really a "default" clause per se, more of a "catch-all" clause, which is useful for providing a default value if none of the provided patterns match. Often though, it will be used to prevent a match error (no matching pattern found), and raise a more meaningful error.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top