Ruby Freak wrote: > What is the difference between class_eval and "class << object"? > > It seems like they are the same. I am thinking that class_eval affects > the greater class and "class_object" is used on a singleton class. > Are > they mutually exclusive? > class Dog attr_accessor :age def initialize(a) @age = a end end class << Dog def greet puts "hello" end end Dog.class_eval{ def show puts @age end } Dog.greet #hello d = Dog.new(5) d.show #5 -- Posted via http://www.ruby-forum.com/.