What does -> _ => mean in Scala/Lift?
Asked Answered
B

1

10

In "Simply Lift" REST examples we can find

case Nil JsonGet _ => Item.inventoryItems: JValue

but

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

Why -> _ => instead of _ =>? And what's that Nil for?

Barograph answered 6/12, 2011 at 21:30 Comment(0)
K
13

This was a topic on the mailing list recently: Help understanding RestHelper serve params.

Basically, it is a series on unapply methods written in infix style. This means it is equivalent to writing it

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

and

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

which makes it appear a bit less voodoo.

Karttikeya answered 6/12, 2011 at 21:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.