我有一个界面,在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
和 IAnimal
在 IBird.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
andIBird.fs
must come afterIAnimal.fs
.
关于f# - 类型 'obj' 不是接口(interface)类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49253533/