Reputation: 493
I have the addition function:
let addition a b = a + b
but I want specify the types:
let addition(a: int, b: int): int = a + b
The question is I want specify the type without use a tuple to build the function. For example, with a incorrect syntax:
let addition a:int,b:int :int = a + b
Upvotes: 3
Views: 58
Reputation: 36688
The syntax you want is:
let addition (a : int) (b : int) : int = a + b
I've put spaces before and after each colon because that's my preference, but you don't have to have those spaces. You could also write:
let addition (a: int) (b: int): int = a + b
and that would work as well.
Upvotes: 3