Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to understand the Anorm parser?

From http://www.playframework.org/documentation/2.0/ScalaTodoList

What does the "~" do and why I don't need a point before map?

val task = {
  get[Long]("id") ~ 
  get[String]("label") map {
    case id~label => Task(id, label)
  }
}

Thanks for your help.

like image 395
user1091344 Avatar asked Apr 15 '12 15:04

user1091344


1 Answers

The ~ operator is inspired from the Scala parser combinators, it allows to extract two column values from a row.

There is no point before map because in Scala you are not required to write points.

like image 144
Julien Richard-Foy Avatar answered Oct 13 '22 10:10

Julien Richard-Foy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!