Question

I want to print a % sign using F#'s printfn function. After googling the format syntax, this should do the trick: printfn "%%". Apparently not...

F# interactive output:

> printfn "%%";;
%%
val it : unit = ()

Weird...

I'm using F#3.1 and .NET 4.5, the F# interactive session uses .NET 4.0. Same thing.

For reference: printfn "%" doesn't compile (missing format specifier) and printfn "%s" "%" is my current workaround...


Update:

When I change the target F# runtime from 3.1 to 3.0, it works. Is this a bug in the 3.1 runtime?

Was it helpful?

Solution

If printfn "%%" outputs two percent signs (%%) instead of one percent sign (%), then you have to update F# 3.1 to at least version 3.1.1.

If you are using Visual Studio 2013, you can do this via Tools → Extensions and Updates → Updates → Visual Studio Gallery → Visual FSharp Tools.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top