How to select a specific overload of a method?

Asik

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
brianberns

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

Editado en
0

Déjame decir algunas palabras

0Comentarios
Iniciar sesiónRevisión de participación posterior

Artículos relacionados

Function overload with specific number

How to call original synchronous method that has async overload in Xcode 13

How do you overload python class method based on Enum type

Overload method with spread operator not recognized

Overload function/method with template argument

Overload function/method with template argument

Overload C++ method with template arguments : how to make this work for subclass of template?

How to overload convert

How to select a specific mailbox from IMAP server?

SQL - How to select the row that has specific condition?

How to select a specific CSV row with python

How to select a postgreSQL row that contains a specific word

How to remove specific <options> in different <select> with remove()?

how to select specific one from child array

How to select all divs with a specific type in JQuery?

CSS: How to select a specific sibiling element

How to select specific columns in r using regex

How to select specific windows in i3?

CLOS: how to call a less specific method?

Laravel apiResources how to call specific method

How to return specific attributes from a stream method

How to replace a specific string using method?

Optaplanner missing a no-args #countDistinct method overload

Which method overload will be accessible from VBScript?

Overload resolution issue for generic method with constraints

Use default value with C# method overload

Is it possible to overload a generic method by input type?

how to overload an assignment operator in swift

Python: How to overload operator with ast

TOP Lista

CalienteEtiquetas

Archivo