I'm calling a C# API which uses overloads and optional parameters. Unfortunately, one of the overloads is a params object[]
and F# selects it over a more specific overload which I intend to call. How do I make F# select the overload I want?
Here's a small repro. And here is a link to the actual API.
open System
open System.Linq.Expressions
type S =
static member Foo(expression: Expression<Func<int>>, ?gg: string) =
"expression"
static member Foo([<ParamArray>] args: obj[]) =
"params array"
[<EntryPoint>]
let main argv =
// This prints "params array", but I want it to print "expression"
let result = S.Foo(fun () -> 3, "")
printfn "%s" result
0
To call the expression version with two arguments, you need:
let result = S.Foo((fun () -> 3), "")
In your code, you've actually defined a function that returns a (3, "")
tuple, which is only a single argument.
Este artículo se recopila de Internet, indique la fuente cuando se vuelva a imprimir.
En caso de infracción, por favor [email protected] Eliminar
Déjame decir algunas palabras