DEV Community


Posted on

Stuck while learning ruby on rails

Hi all,

I'm learning ruby now and I have this exercise on which I'm stuck but can't figure out why. The picture says it all. I'm supposed to write a loop, it's supposed to end by "end" which it does but I get the error message that a keyword_end is expected.... I tried everything I could think of so now I'm asking help to see what I'm missing.

Take care all and thanks for your help.

Alt Text

Discussion (1)

w3ndo profile image
Patrick Wendo

You need a second end.
Whenever you use the .each do, you essentially open a block of code. And all blocks need to be terminated with end.

So the correct version of the code would be

words.each do |word|
    if word == "redact"
       puts "REDACTED"
      puts words + " "
Enter fullscreen mode Exit fullscreen mode