F#: Implementing interface with function name the same as the keyword begin

淺唱寂寞╮ 提交于 2019-12-10 14:54:58

问题


I am trying to implement the IVector interface which is part of the Microsoft.VisualC.StlClr namespace. It has a member function begin(). If I try to implement the interface then it complains about "unexpected keyword 'begin' in object expression".

Is this because begin is a keyword and I can't implement a member function with that name?

B.


回答1:


you can try to wrap it into backticks. IVector inteface is too big to implement it as sample, so example will be smaller - the code below compiles without any errors.

// C#
public interface ITest
{
    void begin();
}

// F#
type Test() = 
    interface UStatic.ITest with
        member this.``begin``() = ()


来源:https://stackoverflow.com/questions/3864034/f-implementing-interface-with-function-name-the-same-as-the-keyword-begin

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