Browse thread
problem with optional arguments
- Dr. Wolfgang Gehrke
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Dr. Wolfgang Gehrke <wgehrke@d...> |
| Subject: | problem with optional arguments |
Hello,
could someone advice me how to resolve the following problem:
The following works fine:
class test1 ~(a:int) () =
object
val a = abs a
method a = a
method strange x = new test1 ~a:x ()
end
let t1 = new test1 ~a:(-10) ()
But on the other hand with an optional argument it does not compile,
neither:
class test2 ?(a:int) () =
object
val a = abs a
method a = a
method strange x = new test2 ~a:x ()
end
nor in the form below:
class test3 ?(a:int) () =
object
val a = abs a
method a = a
method strange x = new test3 ?a:x ()
end
I do need the use of "new" and do not want to use {<...>} since any new
instance internally changes a.
Thank you,
Wolfgang