What does -> mean in F#?

后端 未结 9 1075
情深已故
情深已故 2020-12-03 02:54

I\'ve been trying to get into F# on and off for a while but I keep getting put off. Why?

Because no matter which \'beginners\' resource I try to look at I see very

9条回答
  •  情深已故
    2020-12-03 03:39

    (a -> b) means "function from a to b". In type annotation, it denotes a function type. For example, f : (int -> String) means that f refers to a function that takes an integer and returns a string. It is also used as a contstructor of such values, as in

    val f : (int -> int) = fun n -> n * 2
    

    which creates a value which is a function from some number n to that same number multiplied by two.

提交回复
热议问题