A curiosity about print AND THEN puts


#1

During lesson 5 in Introduction to ruby, I decided to play around with puts and prints. Below is my code that I used in this lesson, and the output(correct word?) it gave me.

1 puts "blarg" blarg
2 puts "flog" flog
3 print "dog" dogduckbook
4 print "duck" shake
5 puts "book" nil
6 puts "shake"

I understand how to use puts and print, and what nil is about, but how should I separate book from the string(correct word?) dogduckbook? I've tried hitting enter to add a blank line between 3 & 4 giving me the same result.


#2

What do you want to do? Print a new line? Use puts

If you did this to get a newline:

print

then that prints absolutely nothing. puts adds a newline.


#3

my goal is to take

1 puts "blarg" blarg
2 puts "flog" flog
3 print "dog" dogduckbook
4 print "duck" shake
5 puts "book" nil
6 puts "shake"

and turn it into:

blarg
flog
dogduck
book
shake

How would or SHOULD I separate dogduck and book after print "duck" ?
Is there ever a situation where I would do that? I just now thought that maybe to accomplish this same goal, I would instead maybe use all puts and no print?


#4

so:

1 puts "blarg" blarg blarg
2 puts "flog" flog flog
3 puts "dogduck" dogduck
4 puts "book" book
5 puts "shake" shake