rubilicious

Learn Ruby the Hard Way

by Zed Shaw

Example 9

Previous   Next

# the variable days is assigned in a string
days = "Mon Tues Wed Thu Fri Sat Sun"

# the variable months is assigned with line breaks \n means newline
months = "Jan\nFeb\nMar\nApr\nMay\nJun\Jul\nAug"

# the method puts print the string then on a new line it prints 
# the contents of the variable days
puts "Here are the days: ", days

# the method puts print the string then on a new line it prints 
# the contents of the variable months
puts "Here are the months: " , months

# the method puts prints the paragraph 
puts <<PARAGRAPH
  There's something going on here.
  With this PARAGRAPH thing
  We'll be able to type as much as we like.
  Even 4, 5 or even 6 lines if we want 
PARAGRAPH

puts "Here are the months: " , months