【问题标题】:What does -> _ => mean in Scala/Lift?-> _ => 在 Scala/Lift 中是什么意思?
【发布时间】:2012-01-14 11:33:01
【问题描述】:

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

case Nil JsonGet _ => Item.inventoryItems: JValue

但是

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

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

【问题讨论】:

    标签: scala lift


    【解决方案1】:

    这是最近邮件列表上的一个主题: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
    

    这使它看起来不那么巫毒。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-27
      • 2014-01-16
      • 2021-10-24
      • 1970-01-01
      • 2011-12-17
      • 2013-08-05
      • 2014-05-06
      • 2015-12-30
      相关资源
      最近更新 更多