Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

printfn "%A" "c" using F#

By running printfn "%A" "c", I get "c".

By running printfn "%s" "c", I get c.

Why the difference? The same goes for char.

like image 322
Oldrich Svec Avatar asked Mar 16 '12 10:03

Oldrich Svec


People also ask

What is Printfn?

The Print. F# has two basic functions; “printf” and “printfn” to print out the information on console. // Theprintf/printfn functions are similar to the. // Console. Write/WriteLine functions in C#.

How do I print a printf string?

We can print the string using %s format specifier in printf function. It will print the string from the given starting address to the null '\0' character. String name itself the starting address of the string. So, if we give string name it will print the entire string.

What is string format in Java?

In java, String format() method returns a formatted string using the given locale, specified format string, and arguments. We can concatenate the strings using this method and at the same time, we can format the output concatenated string. Syntax: There is two types of string format() method.


1 Answers

The %A specifier tries to hint at object types - the "c" is it trying to show it is a string. When you do %s the compiler knows you want to print a string so it doesn't print the quotes

like image 95
John Palmer Avatar answered Sep 29 '22 02:09

John Palmer