'<<' operator

The eigenclass contains all singleton methods of an object. Those are
methods which don't come from the class of the object but actually
belong to the object itself.

For example:

class A
  def f
    puts 1
  end
end

a_1, a_2 =
  A.new, A.new

# define a singleton method for a_1
def a_1.g
  puts 2
end

# call instance method f (defined in class A)
a_1.f
a_2.f
# call singleton method g (defined in singleton class of a_1)
a_1.g
a_2.g # this doesn't work, because a_2 doesn't have the method

Instead of writing def a_1.g, you could also explicitly define the
method in the eigenclass of a_1:

class << a_1
  def g
    puts 2
  end
end

···

--
Posted via http://www.ruby-forum.com/.