Ross
Ross

Reputation: 88

Specifying type of parameter in F# function declaration

I am just starting out with F# so this is a bit of basic question on best practise with type inference.

I am trying to write a function that works on a TimeSpan. This is a simplified version of what I am trying to do:

let intervalsFromTimespan t = t.TotalMinutes / 5.0 

Clearly this won't work because I need to somehow state that t is a timespan.

Would the correct way be:

let intervalsFromTimespan' t = (t : TimeSpan).TotalMinutes / 5.0

Upvotes: 1

Views: 179

Answers (1)

p.s.w.g
p.s.w.g

Reputation: 149078

Try this:

let intervalsFromTimespan (t : TimeSpan) = t.TotalMinutes / 5.0

Upvotes: 4

Related Questions