Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > strange syntax error in while loop

Reply
Thread Tools

strange syntax error in while loop

 
 
laredotornado
Guest
Posts: n/a
 
      01-23-2008
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[rescription_number + i.to_s] != nil and
params[:description + i.to_s] != nil
session[rescription_number + i.to_s] =
params[rescription_number + i.to_s]
session[:description + i.to_s] =
params[:description + i.to_s]
i++
end # line 11
end

Thanks for your help, - Dave
 
Reply With Quote
 
 
 
 
Sebastian Hungerecker
Guest
Posts: n/a
 
      01-23-2008
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:
ICQ: 205544826

 
Reply With Quote
 
 
 
 
Dominik Honnef
Guest
Posts: n/a
 
      01-23-2008
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[rescription_number + i.to_s] != nil and
> params[:description + i.to_s] != nil
> session[rescription_number + i.to_s] =
> params[rescription_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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
Opinion poll: for loop vs while loop with Iterators. Daniel Pitts Java 14 12-23-2006 05:22 AM
Whats the difference between while loop in Windows message loop and while(1) Uday Bidkar C++ 4 12-12-2006 12:30 PM
while loop in a while loop Steven Java 5 03-30-2005 09:19 PM
PEP-0315--Enhanced While Loop: An idea for an alternative syntax Andrew Koenig Python 46 02-24-2004 07:14 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57