From: hemant Date: 2007-12-19T20:18:36+09:00 Subject: Re: [Rhetoric] Two feature requests for safer Ruby Programming On Dec 19, 2007 4:03 PM, Sylvain Joyeux wrote: > > Above code is going to blow. Why? because request is a method > > defined by ActionPack. > > What can we do to prevent this? or this guy is simply dumb and > > should stop programming? > No. Local variables have higher precedence than method invocation. The > code works as expected (i.e. 'request' is the local variable, not the > method call). > Hmm, I wasn't aware of this. But in spite of this, I have seen issues because of this. Above code works, no doubt. I will try to reproduce the situation where it truly creates problem. > > In my opinion, when unintended override of a method happens, Ruby > > should throw a warning. To silent that warning, one should explicitly > > say you are > > overriding a method. > See the -w flag > > [~]% cat test.rb > class WarningAlreadyExists > def bla > end > end > > > class WarningAlreadyExists > def bla > end > end > > [~]% ruby -w test.rb > test.rb:10: warning: method redefined; discarding old bla I was aware of this, but what I also meant was: class WarningAlreadyExists def bla end end class Foo < WarningAlreadyExists def bla end end Doesn't give any warnings, even with warning flag on. -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org