Jul 4, 2011

f# essential - part 6 - tuple

In other language, a method can not return more than one parameter. There are two way to get around this, use passed-by-reference parameter, or use composite type to encapsulate two or more fields in to one object. Both of them are not elegant. However, f# can express this using a very simple syntax to solve this problem, "tuple", which is a strongly typed structure. Here is an example.

let (x, y, z) = (1, 2, 3)
let x, y, z = 1, 2, 3