Skip to content

Instantly share code, notes, and snippets.

@AngelMunoz
Last active March 31, 2021 17:29
Show Gist options
  • Save AngelMunoz/88ca7f75e19c9850a8c421fecab35666 to your computer and use it in GitHub Desktop.
Save AngelMunoz/88ca7f75e19c9850a8c421fecab35666 to your computer and use it in GitHub Desktop.
string interpolation in F#
// string interpolation in F# can be type safe
// specifying the data type you need in the "hole" of that string
// or you can fallback to the "ToString" one
$"Frank is %i{10} years old"
$"That'ts not %b{true}"
$"Bet' you can't print a list %A{[1;2;3;4]}"
$"Yeah but do tou need to specify data type? %{false}"
// or the equivalent in older versions which is good to use as well
sprintf "Frank is %i years old" 10
sprintf "That'ts not %b" true
sprintf "Bet' you can't print a list %A" [1;2;3;4]
sprintf "Yeah but do tou need to specify data type? %s" "true"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment