在Scala类定义的开头,=>是什么意思?
发布时间:2020-12-16 09:36:44 所属栏目:安全 来源:网络整理
导读:问题的作者 Exchanging type parameters with abstract types写了一个=在他的班级定义的开始。例: abstract class Thing { t = type A type G : Group { type A = t.A } val group: G } 什么是t =意思 ? 因为这很难在Google Co,有人可以给我更多的背景信
问题的作者
Exchanging type parameters with abstract types写了一个=>在他的班级定义的开始。例: abstract class Thing { t => type A type G <: Group { type A = t.A } val group: G } 什么是t =>意思 ? 因为这很难在Google& Co,有人可以给我更多的背景信息或提供一个链接,在哪里可以找到关于这种语言结构的更多信息? 解决方法
这个类的默认命名就是这样。你可以用t替换t =>
如果您的类包含子类,并且您需要访问封闭的自引用,这是有用的。 没有t =>在你的例子中你会写这样的东西: abstract class Thing { type G <: Group { type A = this.A } } 组{类型A = this.A}是一个子类型,所以这将引用组专业本身不是一个东西对象。可能你不会得到你的意思。如果您需要访问Thing自我参考,您应该通过分配自己的参考名称来解决名称冲突 abstract class Thing { another_this = > type G <: Group { type A = another_this.A} } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |