Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby: syntax error, unexpected tIDENTIFIER, expecting ')'

Tags:

syntax

ruby

Working on exercise #26 of Learn Ruby The Hard Way -- correcting a ficticious programmer's bad code.

I've got most of it worked out, but can't even get to testing because I keep getting this syntax error:

syntax error, unexpected tIDENTIFIER, expecting ')'

...on this line:

sentence = "All good\tthings come to those who wait."

I thought that was always the way variables were declared? Since the error was listing parens, I tried those too -- around sentence (even though it made no sense), around the string (both with and without quotes), with the equals sign, without the equals sign...I'm not really sure what the issue is here.

like image 446
emco Avatar asked Jul 06 '13 21:07

emco


1 Answers

Not always errors are on the same lines as interpreter says ;) So it would be better if you include some adjacent lines next time. But as I found these lines are:

puts "We can also do that this way:"
puts "We'd have %d beans, %d jars, and %d crabapples." % secret_formula(start_pont

sentence = "All god\tthings come to those who weight."

words = ex25.break_words(sentence)
sorted_words = ex25.sort_words(words)

From here we see that the line before your specified line doesn't have closing parenthesis ')'.

like image 143
Stas S Avatar answered Sep 20 '22 16:09

Stas S