Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这recentest是一个列表,我想在它的“配置文件”上匹配:空的或恰好一个元素。我可以在 match 语句中本地执行吗?
recentest
val newId = if( recentest.size == 0) 0L else {recentest(0).as[Long]("item_id") + 1}
如果您想在几种情况下匹配任意大小,您可以这样做:
list match { ... case _ if list.length == mySize => ... ... }
val newId = recentest match { case Nil => 0 case h::Nil => h.as[Long]("item_id") + 1 }