Simple options

Category:
Lists, Tuples and Options
Description: Create some optional values, print them and match on them.
Code:
let OptionsSample2() =

let data = Some(1,3)
printfn "data = %A" data;
printfn "data.IsSome = %b" data.IsSome
printfn "data.IsNone = %b" data.IsNone
printfn "data.Value = %A" data.Value

let data2 = None
printfn "data2.IsSome = %b" data2.IsSome
printfn "data2.IsNone = %b" data2.IsNone

Execution Result:
data = Some (1, 3)
data.IsSome = true
data.IsNone = false
data.Value = (1, 3)
data2.IsSome = false
data2.IsNone = true

Last edited Sep 14, 2011 at 2:54 AM by ttliu2000, version 1

Comments

No comments yet.