I got an unexpected demonstration of the double dispatch pattern in real life the other day.
几天前在实际生活中我意外地得到了双重分发模式的一个演示。
We can use a pattern called Double Dispatch to pull out the variation into the subclasses in such a way that we don't break existing interface contracts.
我们可以使用称为双重分发的模式将变化推入子类中,通过这种方式,我们不需要破坏现有的接口定义。
Note that evaluate returns a Double, which means that each case in the pattern match is going to have to evaluate into a Double value.
注意evaluate返回了一个Double,它意味着模式匹配中的每一个case都必须被求值成一个double值。
应用推荐