scala – 什么是List [String~Int]?
发布时间:2020-12-16 09:09:37 所属栏目:安全 来源:网络整理
导读:在浏览play框架的 scala文档( Play Docs)时,我看到了一个我从未见过的语法. val populations:List[String~Int] = { SQL("select * from Country").as( str("name") ~ int("population") * ) } 请问有人请告诉我List [String~Int]中的“?”是什么意思? 解决
在浏览play框架的
scala文档(
Play Docs)时,我看到了一个我从未见过的语法.
val populations:List[String~Int] = { SQL("select * from Country").as( str("name") ~ int("population") * ) } 请问有人请告诉我List [String~Int]中的“?”是什么意思? 解决方法
可能是这个帮助:
scala> class ~[A,B] defined class $tilde scala> List.empty[String~Int] res1: List[~[String,Int]] = List() 实际上,?不是标准库的一部分,这是一个来自play框架的泛型类,它允许使用中缀表示法.在scala中,任何带有2个泛型参数的泛型类都可以使用中缀表示法.例如,以下也有效: scala> class X[A,B] defined class X scala> List.empty[String X Int] res1: List[X[String,Int]] = List() 在您的情况下,您将在Play framework API中找到?的定义. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |