On Sep 16, 3:48 pm, "Jonathan S." <[email protected]> wrote: > I see what you mean. However, > > x=3 > if false > x=2 > end >
An even better example is puts xyz # should raise name error if false xyz = 1 end puts xyz #=> nil The thing is that params isn't initially a local variable - it's a method that then gets shadowed by a local variable, i.e. def xyz "moo" end puts xyz.inspect #=> 'moo' if false xyz = 1 end puts xyz.inspect #=> nil Fred > puts x > > This code outputs 3, not nil. And I think that's a more appropriate > analogy. I really don't understand what's happening though. > > Frederick Cheung wrote in post #1022322: > > > On Sep 16, 2:58pm, "Jonathan S." <[email protected]> wrote: > >> puts params[:entity_selection] > >> end > > >> So if it were the case that the params hash being mentioned could > >> overwrite it, then this version of the code would fail, right? > > > Except that it's not mentioned any more - it's commented out > > ( mentioned is obviously a rather wooly term) > > > Fred > > -- > Posted viahttp://www.ruby-forum.com/. -- 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.

