strange syntax error in while loop

L

laredotornado

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
 
S

Sebastian Hungerecker

laredotornado said:

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
 
D

Dominik Honnef

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,699
Latest member
AnneRosen

Latest Threads

Top