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