gpt4 book ai didi

f# - 类型 'obj' 不是接口(interface)类型

转载 作者:行者123 更新时间:2023-12-02 20:26:54 32 4
gpt4 key购买 nike

我有一个界面,在IAnimal.fs中,

namespace Kingdom
type IAnimal =
abstract member Eat : Food -> unit

以及另一个成功继承它的接口(interface),位于IMammal.fs中。

namespace Kingdom
type IMammal =
inherit IAnimal

但是,当我尝试再次继承它时,出现异常 (IBird.fs)

namespace Kingdom
type IBird =
inherit IAnimal

异常(exception)情况是

The type 'obj' is not an interface type

The type 'IAnimal' is not defined

IAnimalIBird.fs 中在其下方有一条红线。

我尝试复制/粘贴 IMammal 的定义并将 IMammal 更改为 IBird 但仍然遇到相同的错误。还尝试重新启动 Visual Studio。

可能出了什么问题?

最佳答案

Make sure your files are in the correct order in your project. A file can only reference types and values defined in earlier fields. So in this case IMammal.fs and IBird.fs must come after IAnimal.fs.

- TheQuickBrownFox

关于f# - 类型 'obj' 不是接口(interface)类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49253533/

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