OK, this is not really a getter implementation like we can have it in other object-oriented programming, but it is close of it.
We have first to create an human variable with a tuple ("name", age).
Then we have to create two getter functions to retrieve the first and the second parameter of this human variable.
# let human = ("John", 50);; val human : string * int = ("John", 50)
# let getName(a,b)=a;; val getName : 'a * 'b -> 'a = <fun>
# let getAge(a,b)=b;; val getAge : 'a * 'b -> 'b = <fun>
# getName(human);; - : string = "John"
Add new comment