Ruby End of Input Error(For New Rubies)

q
2 min readFeb 16, 2021

Starting to learn to code is a huge feat! Beginning is always the hardest step in any process and errors can understandably get in the way of the magic of code! I know they did for me. I remember being proud of myself for following all the steps very carefully, then trying to run a file and getting an error! I felt so frustrated and in disbelief that I did something wrong! I literally thought something about the terminal was glitching — haha! It’s pretty logical to think errors mean you are doing a bad job, but in the world of coding errors are a tool to help you. If you can read errors, something that might make you step away from your computer for the rest of day can be solved in a matter of seconds. Here I will break down the first error which left me super frustrated and confused.

unexpected end-of-input

Screenshot of terminal. Text on grey background reads 3.times do puts “gumdrop”. Below on black background text reads blog.rb:17: syntax error, unexpected end-of-input, expecting end
blog.rb:17: syntax error, unexpected end-of-input, expecting end

In the example above first it says blog.rb:17, this is very important information. It is telling us which file the error is located on. In this case blog.rb. The number tells us which line on that file it errored out, 17. This might not seem relevant right now, but you can imagine how helpful this will be when working with many interconnected files and many lines of code.

Next it says syntax error, this is the part of the error structure which tells you which type of error is being brought up. Also very helpful, a syntax error is telling you that something about the syntax needs some attention. Then it says unexpected end-of-input, expecting end. This is the money, it is literally telling you what to do! An unexpected end-of-input simply means that you forgot to add an end.

So how can we fix this error and get some sweet gumdrops? Well let’s add that missing end!

yay gumpdrops!

--

--