scala - Scala/Lift 中 -> _ => 是什么意思?

标签 scala lift

在“Simply Lift”REST 示例中我们可以找到

case Nil JsonGet _ => Item.inventoryItems: JValue

但是

case Nil JsonPut Item(item) -> _ => Item.add(item): JValue

为什么是 -> _ => 而不是 _ =>?那 Nil 是做什么用的?

最佳答案

这是最近邮件列表上的一个主题:Help understanding RestHelper serve params .

基本上,它是一系列以中缀风格编写的unapply方法。这意味着它相当于写它

case JsonGet(Nil, _) => Item.inventoryItems: JValue

case JsonPut(Nil, Item(item) -> _) => Item.add(item): JValue // or
case JsonPut(Nil, Tuple2(Item(item), _)) => Item.add(item): JValue
// using that -> denotes a Tuple

这让它看起来不那么巫术了。

关于scala - Scala/Lift 中 -> _ => 是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8407132/

相关文章:

scala - Spark 过滤不起作用

电梯不是用 sbt build 的?

scala - 访问 Lift Scala net.liftweb.util.Box 对象中的实体

scala - Akka Actors 代表所有领域模型

scala - 如何执行仅匹配正则表达式的测试?

performance - Scala 的 .min 如何避免装箱和拆箱的惩罚?

node.js - 如何在 Heroku 部署的 `npm install && bower install` 之前运行 `sbt compile`?

css - 当 Lift 使用 CSS 类用于其自身目的时,如何使用 CSS 来设计由 Lift 提供的网页样式?

scala - Mapper 与 Record/Squeryl

斯卡拉电梯 : uniform authentication with form based login and HTTP basic auth?