问题
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
回答1:
Try this:
let intervalsFromTimespan (t : TimeSpan) = t.TotalMinutes / 5.0
来源:https://stackoverflow.com/questions/20128088/specifying-type-of-parameter-in-f-function-declaration