cm0002@lemmy.world to Programmer Humor@programming.dev · 2 days agoDoes this exist anywhere outside of C++?lemmy.mlimagemessage-square54fedilinkarrow-up1157arrow-down120cross-posted to: programmerhumor@lemmy.ml
arrow-up1137arrow-down1imageDoes this exist anywhere outside of C++?lemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 2 days agomessage-square54fedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareschnurrito@discuss.tchncs.delinkfedilinkarrow-up2·2 days agoKinda in Java, you can call System.out.println or you can call System.out.print and explicitly write the newline.
minus-squareuranibaba@lemmy.worldlinkfedilinkarrow-up2·2 days agoI haven’t looked at the code but I always assumed that println was a call to print with a new line added to the original input. Something like this: void print(String text) { ... } void println(String text) { this.print(text + '\n'); }
minus-squareScoopta@programming.devlinkfedilinkarrow-up2·1 day agoThat is pretty much what it does except it doesn’t hardcode \n but instead uses the proper line ending for the platform it’s running on.
Kinda in Java, you can call System.out.println or you can call System.out.print and explicitly write the newline.
I haven’t looked at the code but I always assumed that
println
was a call toprint
with a new line added to the original input.Something like this:
That is pretty much what it does except it doesn’t hardcode
\n
but instead uses the proper line ending for the platform it’s running on.