0
Why does print("hi") puts("1") Outputs "hi1" When puts("hi") print("1") Outputs hi 1?
4 Antworten
+ 8
puts outputs the text, and then adds a new line afterward. You can see that in the second example.
print outputs the text only, without the extra newline. That's why the outputs are right next to each other in the first example.
+ 1
puts() adds a newline after executing each argument and print() does not. (At least not by default)
ie puts 1 2 3 4 5
outputs:
1
2
3
4
5
where print 1 2 3 4 5
outputs:
12345
0
Or something like that
0
puts add newline..simple