The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

darrylqa (1) [Avatar] Offline
#1
Hi, Enjoying the book so far. On top of pg 122, you say "We're sure you could write a simple implementation... Well I wasn't so sure, but it wasn't too hard. Is below what you had in mind?
type IntOption =
|SomeInt of int
|NoneInt
let parseIntOption(s) =
match Int32.TryParse(s) with
|true, parsed -> IntOption.SomeInt(parsed)
|_ -> IntOption.NoneInt
let testParseIntOption() =
let intOption = parseIntOption("42")
match intOption with
|IntOption.SomeInt(myI) ->
printfn "myI= %d" myI
|IntOption.NoneInt ->
printfn "Dude, an integer please"
testParseIntOption()

Thanks,
Darryl