How does Scala's apply() method magic work?

前端 未结 3 1756
逝去的感伤
逝去的感伤 2020-11-27 12:57

In Scala, if I define a method called apply in a class or a top-level object, that method will be called whenever I append a pair a parentheses to an instance o

3条回答
  •  隐瞒了意图╮
    2020-11-27 13:44

    I ask because it seems like Scala strongly favors consistent application of a smaller set of rules, rather than many rules with many exceptions.

    Yes. And this rule belongs to this smaller set.

提交回复
热议问题