From: Gary Wright Date: 2008-11-02T09:24:36+09:00 Subject: Re: How to access to local variables in enclosing scopes? On Nov 1, 2008, at 6:38 PM, Yuh-Ruey Chen wrote: > Okay, there are several little quirks of Ruby that annoy me, but I'll > just a list a couple: > > 1) When I saw the method! notation for mutation methods, I thought > that was particularly brilliant. The method! notation is not a notation for mutation methods. That particular syntax is strictly a stylistic convention. It has no inherent semantics from the language perspective. The convention is that the bang method is more 'dangerous' than the 'regular' non-bang method. The meaning of 'dangerous' is completely relative to the the method and class context. Sometimes it means that the object will be mutated but sometimes it means something else. Since the convention is based on comparing two methods (m and m!) it breaks the convention to define m! without also defining m. > 2) Awkwardness of defining singleton methods. Contrast: > > class << obj > def singleton_method > 'foo' > end > end > > with: > > obj.singleton_method = function() { > return 'blah' > } Try: def obj.singleton_method 'foo' end