# New to Ruby

**URL:** <https://www.ruby-forum.com/t/new-to-ruby/91281>\
**Category:** Ruby-Forum\
**Created:** [April 6, 2007, 7:38am UTC](https://www.ruby-forum.com/t/new-to-ruby/91281 "2007-04-06T07:38:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fairylights](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e56c9b/32.png) [@fairylights](https://www.ruby-forum.com/u/fairylights)\
**Post date:** [April 6, 2007, 7:38am UTC](https://www.ruby-forum.com/t/new-to-ruby/91281/1 "2007-04-06T07:38:08Z")

</div>

class ArrayPlus  
count = sum = 0  
def sums  
11.times do  
count += 1  
sum += count  
print "sum at " + count.to\_s + “=” + sum.to\_s  
end

when I executed this code Ruby points at the last line of the code and  
gives me this error. me “syntax error, unexpected $end, expecting kEND  
end”.

I still can’t understand what I should do to make this code work. Please  
point me in the right direction.

thankyou

---

<div class="post-metadata">

**Author:** ![fairylights](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e56c9b/32.png) [@fairylights](https://www.ruby-forum.com/u/fairylights)\
**Post date:** [April 6, 2007, 7:43am UTC](https://www.ruby-forum.com/t/new-to-ruby/91281/2 "2007-04-06T07:43:28Z")

</div>

Gayathri Vijayakumar wrote:

> class ArrayPlus  
> count = sum = 0  
> def sums  
> 11.times do  
> count += 1  
> sum += count  
> print "sum at " + count.to\_s + “=” + sum.to\_s  
> end
> 
> when I executed this code Ruby points at the last line of the code and  
> gives me this error. me “syntax error, unexpected $end, expecting kEND  
> end”.
> 
> I still can’t understand what I should do to make this code work. Please  
> point me in the right direction.
> 
> thankyou

sorry people wrong place to post I suppose, is there a forum for  
beginners where I can find some answers?

---

<div class="post-metadata">

**Author:** ![fairylights](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e56c9b/32.png) [@fairylights](https://www.ruby-forum.com/u/fairylights)\
**Post date:** [May 19, 2007, 11:16pm UTC](https://www.ruby-forum.com/t/new-to-ruby/91281/3 "2007-05-19T23:16:50Z")

</div>

Gayathri Vijayakumar wrote:

> Gayathri Vijayakumar wrote:
> 
> > class ArrayPlus  
> > count = sum = 0  
> > def sums  
> > 11.times do  
> > count += 1  
> > sum += count  
> > print "sum at " + count.to\_s + “=” + sum.to\_s  
> > end  
> > end

add another ‘end’ to the very bottom

---

<div class="post-metadata">

**Author:** ![fairylights](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/e56c9b/32.png) [@fairylights](https://www.ruby-forum.com/u/fairylights)\
**Post date:** [July 2, 2007, 1:47am UTC](https://www.ruby-forum.com/t/new-to-ruby/91281/4 "2007-07-02T01:47:25Z")

</div>

Guest wrote:

> Gayathri Vijayakumar wrote:
> 
> > Gayathri Vijayakumar wrote:
> > 
> > > class ArrayPlus  
> > > count = sum = 0  
> > > def sums  
> > > 11.times do  
> > > count += 1  
> > > sum += count  
> > > print "sum at " + count.to\_s + “=” + sum.to\_s  
> > > end  
> > > end
> 
> add another ‘end’ to the very bottom

This is correct, but here’s a bit more explanation: “$end” is the actual  
end of the file, whereas “kEND” is the keyword “end”. So it’s basically  
saying that it was expecting another keyword end when the file ended, ie  
there’s a missing ‘end’ somewhere. In this case, it’s missing from the  
end of your ‘do’ block: you need an end for the do, an end for the sums  
method and an end for the class.

This is my least favourite thing about ruby - it gives you no feedback  
as to where the missing ‘end’ might be.
