[ next ] [ prev ] [ contents ] [ up to The Top Ten Reasons I Like Ruby ] Invitation To Ruby

Reason 3 -- Metaclasses

  1: class Dog ... end
  2: d = Dog.new
  3: 
  4: d.methods       # returns list of methods for Dogs (e.g. bark)
  5: Dog.methods     # returns list of methods for Dog Classes (e.g. new)
  6: 
  7: d.type          # returns Dog
  8: Dog.type        # returns Class

Adavantages of Metaclasses

See Metaclass Example


[ next ] [ prev ] [ contents ] [ up to The Top Ten Reasons I Like Ruby ] Copyright 2002 by Jim Weirich.
All rights reserved.