问题
Trying to get optional parameters working in a module I tried changing the let
to member
and static member
but that yields errors.
Error FS0010 Unexpected keyword 'member' in definition. Expected incomplete structured construct at or before this point or other token.
OK syntax:
module Kingdom =
let Rule years = ()
Bad syntax
module Kingdom =
member this.Rule years = ()
Can you not define a member
in a module?
回答1:
As documentation states
Members are features that are part of a type definition [...] F# object types such as records, classes, discriminated unions, interfaces, and structures support members.
That's why you cannot define member
in module
directly.
来源:https://stackoverflow.com/questions/56597149/unexpected-keyword-member-in-definition-in-a-f-module