From: Simen Edvardsen Date: 2006-06-02T19:33:46+09:00 Subject: Re: object::foo syntax -- get a Method object? On 6/2/06, Dave Burt wrote: > Hi, > > At the moment, "obj::foo" means the same as "obj.foo"; that is, > "obj.send(:foo)". > They're not the same: $ irb irb(main):001:0> class Test irb(main):002:1> class InnerTest irb(main):003:2> end irb(main):004:1> end => nil irb(main):005:0> Test.InnerTest NoMethodError: undefined method `InnerTest' for Test:Class from (irb):5 from :0 irb(main):006:0> Test::InnerTest => Test::InnerTest irb(main):007:0> > I propose that it be changed to mean "obj.method(:foo)" instead. > > Although the obj.foo syntax is generally preferred, the obj::foo syntax > is commonly used for class methods in the standard library, so I assume > such a change is too incompatible for use in the 1.8 branch. > > This would provide simpler access to method objects in case you want to > use them functionally, pass them around as blocks, etc. It would mean > that (as in Python, C++ and other languages) it's as easy to refer to a > method object as to call the method, whereas currently that requires a > wordy method call. > method (six characters) is not wordy at all. Method objects are convenient, but I don't think that justifies special syntax. > We don't need two such similar ways to call a method - the dot is fine. > > What do you think? > > Cheers, > Dave > > I say leave it as it is. -- - Simen