F# 名称空间中类的可见性
为什么条形图在Foo中不可见?F#声明是自上而下处理的,因此F# 名称空间中类的可见性,f#,F#,为什么条形图在Foo中不可见?F#声明是自上而下处理的,因此条形图在Foo中引用时未定义。您需要将Bar的定义移动到Foo上方 如果您的类型是相互依赖的,那么您可以使用和来声明它们 namespace Test type Foo() = member this.HelloFoo = "Foo" member this.HelloFooBar = let b = new Bar() // Why is Bar not visible here?
条形图在Foo
中引用时未定义。您需要将Bar
的定义移动到Foo
上方
如果您的类型是相互依赖的,那么您可以使用和来声明它们
namespace Test
type Foo() =
member this.HelloFoo = "Foo"
member this.HelloFooBar =
let b = new Bar() // Why is Bar not visible here?
this.HelloFoo + b.HelloBar
type Bar() =
member this.HelloBar = "Bar"
F#声明是自上而下处理的,因此未在Foo
中引用的点定义Bar
。您需要将Bar
的定义移动到Foo
上方
如果您的类型是相互依赖的,那么您可以使用和来声明它们
namespace Test
type Foo() =
member this.HelloFoo = "Foo"
member this.HelloFooBar =
let b = new Bar() // Why is Bar not visible here?
this.HelloFoo + b.HelloBar
type Bar() =
member this.HelloBar = "Bar"