Jacques Le Normand wrote:
> Hello list,
> I'm trying to define a method with a default argument, but I keep
> getting an error. Here's the code:
>
> class foo =
> object (self)
> method bar ?(baz="moo") () =
> (new foo)#bar ~baz ()
> end
>
> and the error:
>
> The expression "new fo
This should work:
# class foo =
object
method bar =
let helper a b ?(c = "") () =
Printf.printf "a = %d; b = %b; c = %s\n" a b c in
helper
end;;
class foo : object method bar : int -> bool -> ?c:string -> unit -> unit end
Any undesired side effects?
--
Paolo
~
~
:
Hello list,
I'm trying to define a method with a default argument, but I keep getting an
error. Here's the code:
class foo =
object (self)
method bar ?(baz="moo") () =
(new foo)#bar ~baz ()
end
and the error:
The expression "new foo" has type foo but is used with type
< bar : baz: