On Feb 5, 2010, at 8:44 AM, reube...@gmail.com wrote:

Not sure if I worded that Subject line correctly... :P

Anyway, I want to be able to do something similar to the following
when processing form data:

1..5.each do |number|
 if params[:data][number] == '1'        # <-- using block variable
"number" as a hash key does not seem to work...
   foo.bar
 end
end

The if statement is never evaluated as true, but at the same time no
errors pop up.

What is the proper means of doing the equivalent?

You probably want (note the .to_s)

if params[:data][number.to_s] == '1'

-philip

--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to