Re:Yehuda Katz's 10 Favorite Things About Ruby
by dylanz on Monday August 24, 2009 @04:00PM
(#783143)
Articulated perfectly! Any time I'm working on a Rails project, and run into odd behaviours, the first thing I'll do is check to see if I'm actually using a Ruby or a Rails method. Most often than not, I'm expecting a "Ruby" way of doing things, but find out I'm actually using the "Rails" version, which does something completely different. If I run into any in the next few hours, I'll post them here :)
[ Parent
| on HN ]
Re:Yehuda Katz's 10 Favorite Things About Ruby
by carbon8 on Monday August 24, 2009 @04:12PM
(#783186)
It's not really a Ruby vs Rails way of doing things. The Rails implementation is arguably more in line with the standard Ruby behavior since it throws a NoMethodError for everything other than Nil objects.
Re:Yehuda Katz's 10 Favorite Things About Ruby
by defunkt on Monday August 24, 2009 @04:18PM
(#783216)
I would argue that, no, there isn't "standard Ruby behavior" in this instance. It's just a method.
Re:Yehuda Katz's 10 Favorite Things About Ruby
by carbon8 on Monday August 24, 2009 @05:14PM
(#783383)
True, they are all just methods, but it's basically just an altered version of Object#send, and the current Rails implementation only significantly differs from it in the specific situation it's intended for.
I realize there are a range of preferences regarding ways to tackle the problem this is intended to solve, and I'm relatively agnostic about the overall issue, but if the implementation is basically a #send that guards against nil, then it would be unexpected for it to deviate remarkably from #send when dealing with non-nil objects.