# Strange syntax error in while loop

**URL:** <https://www.ruby-forum.com/t/strange-syntax-error-in-while-loop/126951>\
**Category:** Ruby\
**Created:** [January 23, 2008, 6:25pm UTC](https://www.ruby-forum.com/t/strange-syntax-error-in-while-loop/126951 "2008-01-23T18:25:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 23, 2008, 6:25pm UTC](https://www.ruby-forum.com/t/strange-syntax-error-in-while-loop/126951/1 "2008-01-23T18:25:47Z")

</div>

Hi,

I’m getting the error

SyntaxError in OrderController#confirm  
/usr/local/apache2/htdocs/easyrx/app/controllers/order\_controller.rb:  
11: syntax error, unexpected kEND  
end ^  
/usr/local/apache2/htdocs/easyrx/app/controllers/order\_controller.rb:  
33: syntax error, unexpected $end, expecting kEND

in this method:

```
    def confirm
            i = 0
            while params[:prescription_number + i.to_s] != nil and

```

params[:description + i.to\_s] != nil  
session[:prescription\_number + i.to\_s] =  
params[:prescription\_number + i.to\_s]  
session[:description + i.to\_s] =  
params[:description + i.to\_s]  
i++  
end # line 11  
end

Thanks for your help, - Dave

---

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 23, 2008, 7:00pm UTC](https://www.ruby-forum.com/t/strange-syntax-error-in-while-loop/126951/2 "2008-01-23T19:00:10Z")

</div>

laredotornado wrote:

> ```
> i++
> 
> ```
> 
> end

Ruby doesn’t have the ++ operator and parses the above as binary plus  
followed  
by unary plus, i.e. “i + (+end)”. Thus the syntax error.

HTH,  
Sebastian

---

<div class="post-metadata">

**Author:** ![laredotornado](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@laredotornado](https://www.ruby-forum.com/u/laredotornado)\
**Post date:** [January 23, 2008, 7:03pm UTC](https://www.ruby-forum.com/t/strange-syntax-error-in-while-loop/126951/3 "2008-01-23T19:03:08Z")

</div>

On [Thu, 24.01.2008 02:24], laredotornado wrote:

> ```
> i++
> end # line 11
> end
> 
> ```
> 
> Thanks for your help, - Dave

Ruby doesn’t know ++, so you have to write i+=1
