[LRUG] Global methods vs. Kernel mixins

Tejas Dinkar tejas at c42.in
Thu Jul 18 03:43:00 PDT 2013


On Jul-18-2013, at 1:59 PM, Hemant Kumar <hemant at codemancers.com> wrote:
> In Ruby no matter where you are, you always have a `self` object. When you inside a instance method of a class, self is the instance of that class. When you are defining a class method, `self` is the class. 
> 
> Ruby also has a concept of "default definee". When you define a method without an explicit receiver, the method is defined as instance method in the "default definee" class. 
> 
> When you are in global scope, the self is an object called 'main'.  Object 'main' is a very special object in Ruby. It is an instance of class `Object` itself and very curiously has dual nature, which means it can behave as an object and sometimes as a class.


This is a good read on the subject, even if it doesn't answer the question explicitly

http://yehudakatz.com/2009/11/15/metaprogramming-in-ruby-its-all-about-the-self/
 --
Tejas Dinkar
http://www.nilenso.com
m: (+91) 98455 72696
skype: tdinkar

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130718/7fefb486/attachment.html>


More information about the Chat mailing list