Tuples in F#
March 11, 2017 1 Comment
Tuples are collections where each element can be of different type. If you have a C# or Python background then you must be familiar with tuples. A tuple can be used to return multiple values from a function without having to declare an object for it.
Here’s a tuple with 5 elements:
let addThreeNumbers x y z = x + y + z let myFirstTuple = (45, "hello world", 5., true, addThreeNumbers)
This tuple has an integer, a string, a float, a boolean and a function in it.
val myFirstTuple : int * string * float * bool * (int -> int -> int -> int) = (45, “hello world”, 5.0, true, )