-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAboutUnit.fs
More file actions
30 lines (25 loc) · 968 Bytes
/
AboutUnit.fs
File metadata and controls
30 lines (25 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
namespace FSharpKoans
open FSharpKoans.Core
open Microsoft.FSharp.Reflection
//---------------------------------------------------------------
// About Unit
//
// The unit type is a special type that represents the lack of
// a value. It's similar to void in other languages, but unit
// is actually considered to be a type in F#.
//---------------------------------------------------------------
[<Koan(Sort = 5)>]
module ``about unit`` =
[<Koan>]
let UnitIsUsedWhenThereIsNoReturnValueForAFunction() =
let sendData data =
//...sending the data to the server...
()
let x = sendData "data"
AssertEquality x __ //Don't overthink this. Note also the value "()" displays as "null" in some cases.
[<Koan>]
let ParameterlessFunctionsTakeUnitAsTheirArgument() =
let sayHello() =
"hello"
let result = sayHello()
AssertEquality result __