[英]F# Method Definition Syntax
I have a method (static in this case) and I can't quite figure out the exact syntax for defining it. 我有一个方法(在这种情况下是静态的),我不太清楚定义它的确切语法。
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>()
It fails on the colon between startNode
and the first Node with: 它在
startNode
和第一个Node之间的冒号上失败,显示:
"Syntax error in labelled type"
“标记类型中的语法错误”
What would be the best way to make a method like this? 制作这样的方法的最佳方法是什么?
To make it multiline you can just make the calls on separate lines 要使其成为多线电话,您可以仅在单独的线路上进行通话
static member FindPath (startNode : Node) (endNode : Node) (nodes : List<Node>) =
let resultOfMethod1 = CallMethod1()
CallMethod2()
new Queue<Node>()
Also i removed the return type because you shouldn't need it if you return a queue like that 我也删除了返回类型,因为如果您返回这样的队列,则不需要它
static member FindPath (startNode : Node)
(endNode : Node)
(nodes : List<Node>)
: Queue<Node>
= new Queue<Node>()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.