首页 > scala模式匹配如果匹配非空List

scala模式匹配如果匹配非空List

我试着用 case x :: Nil => ...匹配出非空的集合,但是这里的x只能是单一的元素,而不能表示一个List。请问,怎么模式匹配如果匹配出非空List?


我已经在这里找到答案了,大家可以参照一下
http://stackoverflow.com/questions/34585248/how-to-use-pattern-match-get-a-nonempty-list-in-scala

【热门文章】
【热门文章】