QP School
The difference between print and puts - Printable Version

+- QP School (https://qomplainerzschool.lima-city.de)
+-- Forum: Tutorials (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=3)
+--- Forum: Ruby 3 Tutorials, exercises and examples (https://qomplainerzschool.lima-city.de/forumdisplay.php?fid=17)
+--- Thread: The difference between print and puts (/showthread.php?tid=2496)



The difference between print and puts - Qomplainerz - 02-26-2021

Print will print whatever you have in one line on the screen, even if there are multiple lines in your code.
For example:


Quote:print 1 + 2
print 2 + 3


This will print the results 3 5 in one line on the screen.

Puts will print whatever you have in a new line on the screen.
For example:


Quote:putsĀ 1 + 2
putsĀ 2 + 3


This will print the results
3
5
in two lines on the screen.