How to put an alphabetic percent sign (%) inside F # printf format strings?

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

Interactive F # output:

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

Weird ...

I use F # 3.1 and .NET 4.5, the F # interactive session uses .NET 4.0. Same.

For reference: printfn "%" does not compile (missing format specifier) ​​and printfn "%s" "%" is my current workaround ...


Update:

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

+6
source share
1 answer

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

If you are using Visual Studio 2013, you can do this using tools β†’ Extensions and Updates β†’ Updates β†’ Visual Studio Gallery β†’ Visual FSharp Tools.

+7
source

Source: https://habr.com/ru/post/970207/


All Articles