Unexpected keyword 'member' in definition, in a F# module

左心房为你撑大大i 提交于 2019-12-11 07:21:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!