Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
default arguments in classes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-06-16 (21:12)
From: Jacques Le Normand <rathereasy@g...>
Subject: default arguments in classes
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 ()

and the error:

The expression "new foo" has type foo but is used with type
  < bar : baz:string -> unit -> 'a; .. >
Types for method bar are incompatible

how do I fix this?
--Jacques L.