- .NET Core 2.0 By Example
- Rishabh Verma Neha Shrivastava
- 190字
- 2021-06-24 18:30:59
F# functions
F# functions act like variables. We can declare and use them in the same way as we use variables in C#. A function definition starts with the let keyword, followed by the function name and parameters, a colon, its type, and the right-side expression, showing what the function does. The syntax is follows:
Let functionName parameters [ : returnType] = functionbody
In the preceding syntax:
- functionName is an identifier of the function.
- parameters gives the list of parameters separated by spaces. We can also specify an explicit type for each parameter and if not specified, the compiler tends to presume it from the function body as variables.
- functionbody comprises an expression, or a compound expression, which has number of expressions. The final expression in the function body is the return value.
- returnType is a colon followed by a type and it is optional. If the returnType is not specified, then the compiler determines it from the final expression in the function body.
Have a look at the following example for our syntax:
let addValue (x : int) = 5 + x
推薦閱讀
- 物聯(lián)網(wǎng)射頻識別(RFID)技術與應用
- GitLab CI/CD 從入門到實戰(zhàn)
- 企業(yè)性能測試:體系構建、落地指導與案例解讀
- Docker源碼分析
- 網(wǎng)絡空間測繪技術與實踐:讓互聯(lián)網(wǎng)情報服務于網(wǎng)絡安全
- MATLAB 2018從入門到精通
- Java高手真經(jīng)·編程基礎卷:Java核心編程技術
- 從缺陷中學習C/C++
- Swift權威指南
- 微服務架構原理與開發(fā)實戰(zhàn)
- 每天5分鐘玩轉OpenStack
- 多面體編譯理論與深度學習實踐
- 36個創(chuàng)意電子小制作:安全衛(wèi)士
- Android驅動開發(fā)與移植實戰(zhàn)詳解
- 軟件工程:理論與實踐(第2版)