[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

strange syntax error in while loop

(D. Alvarado)

1/23/2008 5:23:00 PM

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
2 Answers

Sebastian Hungerecker

1/23/2008 5:59:00 PM

0

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
--
Jabber: sepp2k@jabber.org
ICQ: 205544826

Dominik Honnef

1/23/2008 6:02:00 PM

0

On [Thu, 24.01.2008 02:24], laredotornado wrote:
> 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


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

--
Dominik Honnef