I'm doing Ruby the Hard Way (ex9) -> http://ruby.learncodethehardway.org/book/ex9.html
Why can it not find the constant PARAGRAPH?
ERROR =>:
$ ruby ex9.rb
ex9.rb:9: uninitialized constant PARAGRAPH (NameError)
CODE (my input):
# Here's some new strange stuff, remember type it exactly.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\n\Feb\nMar\nApr\nMay\nJun\nJul\nAug"
puts = "Here are the days: ", days
puts = "Here are the months: ", months
puts <<PARAGRAPH
Theres something going on here.
With the paragraph thing.
Well be able to type as much as we like.
Even four lines.
PARAGRAPH
NOTE: I modified the code in paragraph and stripped integers and possible statements like "if or "or" just to make sure I wasn't doing something else wrong. With the "right" code I get the following...
LESSON CODE ERROR =>:
ex9.rb:12: syntax error, unexpected tIDENTIFIER, expecting $end
We'll be able to type as much as we like.
^
LESSON CODE: (my input)
# Here's some new strange stuff, remember type it exactly.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "Jan\n\Feb\nMar\nApr\nMay\nJun\nJul\nAug"
puts = "Here are the days: ", days
puts = "Here are the months: ", months
puts <<PARAGRAPH
There's something going on here.
With the PARAGRAPH thing
We'll be able to type as much as we like.
Even 4 lines if we want, or 5, or 6.
PARAGRAPH
Like Some Guy said, assigning
"Here are the days: ", daystoputsis your problem. When you hit the lineputs <<PARAGRAPHthe interpreter attempts to appendPARAGRAPHto the arrayputsinstead of generating the here doc, but of coursePARAGRAPHis undefined.Its kind of interesting, (though not super helpful) to note that you could actually still force it to work with the syntax