From: "Jan E." Date: 2012-04-17T09:19:48+09:00 Subject: Re: A Beginner's Question about Metaprogramming Phil Stone wrote in post #1056802: > But when I say > class MyClass > def self.hello > "hi" > end > end > > The above is also true in this example: No other class gets the "hello" > method, and I didn't have to use a Singleton method. This *is* a singleton method. It's just a different syntax: Instead of explicitly opening the singleton class of "my_object" and defining the method "my_method" in it, you can also write def my_object.my_method ... ... end It's kind of a short form. However, you cannot use the "def" syntax for dynamic method definitions. That's why you either have to open the singleton class explicitly or call Module#define_singleton_method, which is available in Ruby 1.9 (like I suggested earlier). -- Posted via http://www.ruby-forum.com/.