On Oct 17, 10:27 pm, John Merlino <[email protected]> wrote:
> Hey all,
>
> THis line of code gets called multiple times and creates a hash:
>
>   def session_code(unit_id, code)
>
>     s_code = session[:code]
>     unit_id_hash = s_code.detect {|h| h[unit_id]}
>
>     if unit_id_hash.nil?
>       unit_id_hash = {}
>       s_code << {unit_id => unit_id_hash}
>     end

The two branches of this code result in unit_id_hash looking somewhat
different .

In the case where you find something in s_code, what you're setting
unit_id_hash to is something of the form {unit_id => {...}} whereas I
expect you're expect it to be the value from that hash for the key
unit_id

Fred

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to