我发现自己经常写这样的代码:
thing match {
case Case1 ...
case Case2 ...
case _ => throw new IllegalStateException(s"unexpected $thing")
}
有时,当案例不匹配时,我想要一个运行时错误。案例是一种断言形式。
有没有更好的方法来抑制穷举检查?
我不想使用[@unchecked](https://www.scala-lang.org/api/2.12.1/scala/unchecked.html)
,因为这也会禁用可达性检查,这是我想要的。