Вопрос

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?

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top