Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "Syntax Error, unexpected tCONSTANT" error in Ruby?

I am currently on Lesson 9 in "Learn Ruby the hard way".

I have typed the the line number 6 exactly as the way its being instructed but still I am getting error while executing.

It says:

Syntax error, unexpected tCONSTANT, expecting $end
puts " Here ^ are the days : ", days 
like image 997
The Realmccoy Avatar asked Sep 06 '11 08:09

The Realmccoy


1 Answers

You have forgotten to close a string on a previous line. Here's the problem reproduced:

paul@paulbookpro ~ ⸩ ruby     
days = "abc
puts "Here are the days"
-:2: syntax error, unexpected tCONSTANT, expecting $end
puts "Here are the days"
          ^

It's treating the double-quote before the word "Here" as the closing quote of the string on the previous line, and then wondering why you're using a constant called Here (token beginning with upper case letter).

like image 126
Paul Annesley Avatar answered Sep 23 '22 07:09

Paul Annesley