While going through the scala documentation ( Play Docs ) of the play framework I saw a syntax I have never seen before.
val populations:List[String~Int] = {
SQL("select * from Country").as( str("name") ~ int("population") * )
}
Could someone please tell me what does "~" in List[String~Int]
mean?
May be this willl help:
scala> class ~[A, B]
defined class $tilde
scala> List.empty[String~Int]
res1: List[~[String,Int]] = List()
Actually, ~
is not a part of the standard library, this is a generic class from the play framework, which allows an infix notation. In scala, any generic class that takes 2 generic parameters can be use with an infix notation. for example, the following also works:
scala> class X[A, B]
defined class X
scala> List.empty[String X Int]
res1: List[X[String,Int]] = List()
In your case, you will find the definition of ~
in the Play framework API .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.