You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think fmt#Print and fmt#Println are pretty similar commands.
They can both print a series of objects by concatenating them.
However, Println puts a whitespace in between every parameter, which Print does not: https://play.golang.org/p/wItyuCLSuSq
In the docs it says
Print: Spaces are added between operands when neither is a string. Println: Spaces are always added between operands [...]
What did you expect to see?
I'd think for the two to behave the same, except that Println appends a newline character.
What did you see instead?
In the example I linked above, Println concats the two strings supplied by placing a whitespace in the middle.
On the other hand, Print does not put anything in between the two strings.
I noticed this inconsistency when changing calls to fmt.Println to fmt.Print in my codebase in order to increase readability.
I had to add many spaces which were not needed before.
My question is whether this is the supposed behaviour?
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I think
fmt#Print
andfmt#Println
are pretty similar commands.They can both print a series of objects by concatenating them.
However,
Println
puts a whitespace in between every parameter, whichPrint
does not:https://play.golang.org/p/wItyuCLSuSq
In the docs it says
What did you expect to see?
I'd think for the two to behave the same, except that
Println
appends a newline character.What did you see instead?
In the example I linked above,
Println
concats the two strings supplied by placing a whitespace in the middle.On the other hand,
Print
does not put anything in between the two strings.I noticed this inconsistency when changing calls to
fmt.Println
tofmt.Print
in my codebase in order to increase readability.I had to add many spaces which were not needed before.
My question is whether this is the supposed behaviour?
The text was updated successfully, but these errors were encountered: