This appears to work:

1
2
3
4
5
6
7
8
9
10
type Optional() =
  abstract Foo:int * [<OptionalArgument>]b : int option -> unit
  default x.Foo(a, ?b:int) =
    match b with
      | Some _ -> ()
      | _ -> ()
  member x.Bar (a, ?b:int) =
    match b with
      | Some _ -> ()
      | _ -> ()
By on 3/16/2010 10:56 AM ()

Ah, I was wrong, kvb's version works, as does the more obvious

1
2
3
4
5
6
7
8
9
10
type Optional() =
    abstract Foo:int * ?b : int -> unit
    default x.Foo(a, ?b:int) =
        match b with
        | Some _ -> ()
        | _ -> ()
    member x.Bar (a, ?b:int) =
        match b with
        | Some _ -> ()
        | _ -> ()
By on 3/16/2010 1:59 PM ()

Thanks for both options!

I believe I tried second approach, but probably made some typo during my attempts.

By on 3/18/2010 6:03 AM ()

I don't think so.

(You can always use overloading instead.)

By on 3/16/2010 10:07 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper