I play in the f # interactive window and find that printf is not working as I expected. In the following snippet ReadLine runs before the first printf
let run () = printf "What is your name?" Console.Out.Flush() let value = System.Console.ReadLine() printf "Hello, %s, nice to meet you!" value run()
If I change printf to Console.WriteLine, it works as expected.
let run () = Console.Out.WriteLine "What is your name?" Console.Out.Flush() let value = System.Console.ReadLine() printf "Hello, %s, nice to meet you!" value run()
What happens with printf? Is there a flush call that I can print before reading? Is there a f # read line I should use?
----------------- [Change] --------------------
After reading the answer of Fedor Soikin, I tried to check the following. Of course, what was printed on the screen was Hello , and after entering some input, it printed World .
open System let run () = printf "Hello\n World" let value = System.Console.ReadLine() let msg = sprintf "Hello, %s, nice to meet you!" value printf "%s" msg run()
source share