F#方法定义语法

时间:2009-06-14 06:11:50

标签: syntax f# methods definition

我有一个方法(在这种情况下为静态),我无法弄清楚定义它的确切语法。

static member FindPath : Queue<Node> startNode : Node endNode : Node nodes : List<Node> = 
    //this method will call two other to be constructed methods and return a 
    //queue that is the return value of one of them
    return new Queue<Node>()

startNode与第一个节点之间的冒号失败:

  

“标记类型中的语法错误”

制作这样的方法的最佳方法是什么?

2 个答案:

答案 0 :(得分:5)

要使其成为多线,您可以在不同的线路上进行呼叫

static member FindPath (startNode : Node) (endNode : Node) (nodes : List<Node>) = 
        let resultOfMethod1 = CallMethod1()
        CallMethod2()
        new Queue<Node>()

此外,我删除了返回类型,因为如果返回类似

的队列,则不需要它

答案 1 :(得分:3)

static member FindPath (startNode : Node)
                       (endNode : Node)
                       (nodes : List<Node>)
                     : Queue<Node>
   = new Queue<Node>()
相关问题