Usage of parenthesis in F#

后端 未结 1 1499
囚心锁ツ
囚心锁ツ 2020-12-19 04:11

I am having an issue understanding the usage of parenthesis in F#. To illustrate with a simple example, the 2 following console apps behave very differently. The first one d

相关标签:
1条回答
  • 2020-12-19 04:48

    If a function takes no parameters, you specify the unit value () as the argument, as in the following line of code.

    initializeApp()
    

    The name of a function by itself is just a function value, so if you omit the parentheses that indicate the unit value, the function is merely referenced, not called.

    http://msdn.microsoft.com/en-us/library/dd233229.aspx

    That is why you have to do Console.ReadLine() rather than Console.ReadLine ( the latter returns a function delegate)

    0 讨论(0)
提交回复
热议问题