I understand that (class << self; self; end) returns the singelton class
of object that is calling it but why would use that instead of self <<
MyClass ...?

For example, arent these all equivalent?

class << String
  def foo
    puts "foo"
  end
end

class String
  class << self
    def foo
      puts "foo"
    end
  end
end

class String
  (class << self; self; end).module_eval do
     def foo
       puts "foo"
     end
  end
end

So why would you use the more obscure (class << self; self; end)
technique? Can someone please explain.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to