Forum: Ruby DelegateClass vs. Extending

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D6c15c32412570d3b3c215cec749b441?d=identicon&s=25 Brian Doyle (brianpdoyle2)
on 2007-03-15 15:12
I was looking at DelegateClass example:

  class Tempfile < DelegateClass(File)
    # constant and class member data initialization...

    def initialize(basename, tmpdir=Dir::tmpdir)
      # build up file path/name in var tmpname...

      @tmpfile =, File::RDWR|File::CREAT|File::EXCL,

      # ...


      # below this point, all methods of File are supported...

    # ...

and was wondering what is the advantage of doing this and not just
extending the File class?   Thanks.
This topic is locked and can not be replied to.