gpt4 book ai didi

scala - 扩展另一个结构类型的结构类型

转载 作者:行者123 更新时间:2023-12-02 11:24:38 26 4
gpt4 key购买 nike

为什么不允许出现以下情况? (2.12):

type Foo <: {def foo(): Unit}
type Bar <: {def bar(): Unit} with Foo
对我来说看起来很自然, Bar应该同时拥有 foo()bar() .

最佳答案

似乎与括号一起工作

scala> type Foo <: {def foo(): Unit}
| type Bar <: ({def bar(): Unit}) with Foo
type Foo
type Bar

关于scala - 扩展另一个结构类型的结构类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63856895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com