Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface member with multiple arguments

Tags:

f#

How can I declare interface member with two arguments? Something like:

type IService = 
   abstract myMember: (a:int) (b:string) -> result
like image 973
ceth Avatar asked Oct 27 '25 14:10

ceth


1 Answers

For a function with two arguments:

type IService = 
   abstract member myMember: int -> string -> string

Alternatively, you could use a tuple:

type IService = 
   abstract member myMember: int * string -> string

The reason the syntax is int -> string -> string (where an arrow denotes the return of a function) is because functions with multiple parameters in F# can be partially applied by default.

It's also important to note that if you're writing a library that you intend to consume from other .net languages, you should use the tuple form.

like image 132
William Barbosa Avatar answered Oct 30 '25 14:10

William Barbosa