rubilicious

Learn Ruby the Hard Way

by Zed Shaw

Example 7

Previous   Next

# the method puts prints the string
puts "Mary had a little lamb."

# the method puts prints the string and using string interpolation 
# embeds the variable snow into the string 
puts "It's fleece was white as %s." % 'snow'

# the method puts prints the string
puts "Everywhere that Mary went."

# the method puts prints the integer 10 
puts "." * 10 # What did that do?

# variable are assigned
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"

# the method puts prints the concatonated variables 
puts end1 + end2 + end3 + end4 + end5 + end6
puts end7 + end8 + end9+ end10 + end11 + end12

# the printf method prints to the screen but does not make a line return
printf "Cheeseyburger"

# the method puts is creating a blank line in the terminal
puts