I am facing a problem with an optional argument in a method class.
Let me explain. I have a pathfinding class graph(in the Wally module) and one of its methods shorthestPath. It uses an optional argument. The fact is that I call (with an optional argument or not) this OCaml method returns a conflict of the type:
Error: This expression has type Wally.graph
but an expression was expected of type
< getCoor : string -> int * int;
getNearestNode : int * int -> string;
shorthestPath : src:string -> string -> string list; .. >
Types for method shorthestPath are incompatible
whereas type shorthestPath:
method shorthestPath : ?src:string -> string -> string list
I also tried to use the option format for an optional argument:
method shorthestPath ?src dst =
let source = match src with
| None -> currentNode
| Some node -> node
in
...
Only when I remove the optionnal argument does OCaml stop offending me.
Thank you in advance for your help :)
source
share