On Thu, 29 Dec 2005 05:04:54 -0000, Steve Litt <slitt / earthlink.net> wrote:

> Yeah, on a similar subject, under what circumstances would one want to  
> add a
> method to an object if that method wasn't part of its class?
>

Check out the way open-uri returns an extended string:

   require 'open-uri'

   uri = URI.parse 'http://www.google.com'
                  #<URI::HTTP:0xfdbf049a8 URL:http://www.google.com>

   s = uri.read   #=> "<html> ...[snip]... </html>"
   s.class        #=> String
   s.base_uri     #=> <URI::HTTP:0xfdbf1e54c URL:http://www.google.co.uk/>

for one example. It's actually several methods in this case, from a module.

-- 
Ross Bamford - rosco / roscopeco.remove.co.uk