阅读时this article我来到了以下语法:
implicit val slaveCanRead: Slave HasPrivilege Read = null
作者说:
Also, please not that
Slave HasPrivilege Read
is just another notation forHasPrivilege[Slave, Read]
将示例保持在基本的 Scala 中,该示例也可以是
val foo: Map[String, Long] = Map()
val bar: String Map Long = Map()
我正在寻找一些可以解释这种语法的文档/文章,但找不到。有人可以指出允许这种语法的语言功能吗?
最佳答案
真的就像T1 TCon T2 = TCon[T1, T2]
一样简单.它是 section 3.2.8 of the language specification .
InfixType ::= CompoundType {id [nl] CompoundType}
如果中缀类型以
:
结尾它是右结合的,否则它是左结合的,就像方法一样,混合固定性是一个没有括号的错误。
关于scala - 在scala中声明一个没有方括号的泛型类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46849019/