Reputation: 766
I have a unit test class:
type [<TestFixture>] BetTests()=
[<Test>]
member x.HasGoodOddsTest() =
let ret = HasGoodOdds 10.0
Assert.IsFalse(ret, "Expected false");
and a static method defined outside of the class:
let HasGoodOdds odds = odds >= 20.0
but I'm getting a compiler error: "The value or constructor 'HasGoodOdds' is not defined."
What's the syntax to get outside of the scope of the class? Thanks!
Upvotes: 0
Views: 183
Reputation: 118865
Is HasGoodOdds defined above the BetTests class? Is it defined in the same file?
It needs to be defined above it (in a prior file, or above it in this file - generally you can't reference entities in F# until after they are defined), and if the BetTests class is not defined in the same module, you need to either use a qualified name (as @Vitaliy says) or use an 'open' declaration to bring the namespace/module into scope.
Upvotes: 2
Reputation: 5299
This method should be defined in a module. Use Namespace.ModuleName.Method
convention
Upvotes: 1