F# - Function with no arguments?

后端 未结 2 1435
暗喜
暗喜 2020-12-17 07:39

When thinking in a functional mindset, given that functions are supposed to be pure, one can conclude any function with no arguments is basically just a value.
However,

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-17 08:06

    The usual idiom is to define the function to take one argument of type Unit (let functionName () = 42). It will then be called as functionName (). (The unit type has only one value, which is ().)

提交回复
热议问题