From: Josh Cheek Date: 2011-04-30T08:01:48+09:00 Subject: Re: Is everything object ? --bcaec548a0677b5bec04a216a831 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Apr 29, 2011 at 2:37 PM, Chad Perrin wrote: > > > puts.extend Enumerable > > > > That, of course works, puts evalutaes to nil, nil is an object and > therefore > > has a singleton class, and therefore can be extended. > > It doesn't extend puts; puts is not an object. Trying to think of puts > as an object doesn't work. It gives surprising results if you actually > expect it to behave as an object in and of itself, thus violating the > "objects and methods" model of Ruby. > > > That's because methods are invoked by default, as I already stated. You need a line that evaluates to the method, not to nil. Your issue isn't with the objectivity of methods, it is with how you access methods. # this is evaluated puts # => nil # now we have a reference to it puts = method :puts # => # # and look, we can extend it puts.extend Enumerable # => # puts.singleton_class.ancestors # => [Enumerable, Method, Object, Kernel, BasicObject] --bcaec548a0677b5bec04a216a831--