Stylish F# by Kit Eason

Stylish F# by Kit Eason

Author:Kit Eason
Language: eng
Format: epub
ISBN: 9781484240007
Publisher: Apress


type ConsolePrompt(message : string, beepOnError : bool) =

do

if String.IsNullOrWhiteSpace(message) then

raise <| ArgumentException("Null or empty", "message")

let message = message.Trim()

new (message : string) =

ConsolePrompt(message, true)

member this.GetValue() =

printfn "%s:" message

let input = Console.ReadLine()

if not (String.IsNullOrWhiteSpace(input)) then

input

else

if beepOnError then

Console.Beep()

this.GetValue()

let demo() =

let first = ConsolePrompt("First name", false)

let last = ConsolePrompt("Second name")

// No beep on invalid input!

let firstName = first.GetValue()

// Beep on invalid input!

let lastName = last.GetValue()

printfn "Hello %s %s" firstName lastName



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.