【发布时间】:2012-03-21 13:53:33
【问题描述】:
可能重复:
What is the rationale behind having companion objects in Scala?
感谢所有对我之前帖子的回复(Scala: companion objects and "new" keyword)。我想问你 Scala 中伴生对象的一般用途是什么? 首先,我们不能以类本身的构造函数/方法定义的形式包含所有方法,例如 apply 吗? 此外,伴随布尔对象的意义何在,因为它甚至没有定义应用方法?
再次提前感谢您的所有回复。
【问题讨论】:
-
answer below 比接受的重复答案更好。