斯卡拉新来的。语言很简洁。斯卡拉多个与
奇怪为什么实现多个特征需要多个“with”语句。
例如:
class Foo extends Bar with A with B with C {}
与
class Foo extends Bar with A, B, C {}
斯卡拉新来的。语言很简洁。斯卡拉多个与
奇怪为什么实现多个特征需要多个“with”语句。
例如:
class Foo extends Bar with A with B with C {}
与
class Foo extends Bar with A, B, C {}
考虑这个
class Foo[A, B]
new Foo[Bar with D with E, Bar with E] {}
VS
new Foo[Bar with D, E, Bar with E] {}
这在所有情况下都不是毫不含糊。
ahhh,好的,这说明了多谢的明显非DRY-ness,谢谢。 – virtualeyes
@virtualeyes你可以将'with'看作一个(看起来不同的)逗号 - 应该明显表示没有DRY违规。 – thedayturns
如果你要去那条路线,为什么要“拥有”呢?为什么不'Foo类扩展Bar,A,B,C'? – dhg
又是新的scala,但不支持带“扩展”的afaik多重继承,而“with”提供了这种功能的形式 – virtualeyes