Michael
Michael

Reputation: 133

What's the difference between keyword_end and end-of-input in ruby?

Sometimes, I ran into an error like this in ruby:

syntax error, unexpected keyword_end, expecting end-of-input

So, I want to know the difference between keyword_end and end-of-input

Upvotes: 1

Views: 114

Answers (2)

Makoto
Makoto

Reputation: 106460

keyword_end implies that you had a block of code with a missing end.

def fun(f)
    puts "Oops!"

End-of-input implies that you have already closed up blocks of code with one too many end keywords.

def fun(f)
    puts "Okay..."
end
end

Upvotes: 0

Larry Kooper
Larry Kooper

Reputation: 71

Keyword 'end' is the end statement in Ruby that comes at the end of methods, classes, etc. end-of-input is the actual end of your code file. The message you got means you have an extra 'end' statement somewhere.

Upvotes: 2

Related Questions