Re: Ruby Basics / define met;hod
- From: Robert Klemme <shortcutter@xxxxxxxxxxxxxx>
- Date: Thu, 06 Mar 2008 18:45:34 +0100
On 06.03.2008 17:18, Chinna Karuppan wrote:
I did read through your reply.especially this....
"Inside a class body /self/ is the class instance being defined right
now."
I still could not understand.
You wondered why define_method can be invoked inside class...end because it is private and should not be accessible "from outside". Private methods can normally be only invoked without an explicit receiver, i.e. only on /self/. I explained and demonstrated (via the printing) that inside class...end /self/ is actually the class being defined. Hence you can invoke define_method inside class..end. q.e.d.
Then I went on to explain that /private/ in Ruby is rather weak because you can invoke private methods on any instance simply by going through /send/.
Cheers
robert
.
- References:
- Ruby Basics / define met;hod
- From: Chinna Karuppan
- Re: Ruby Basics / define met;hod
- From: Robert Klemme
- Re: Ruby Basics / define met;hod
- From: Chinna Karuppan
- Re: Ruby Basics / define met;hod
- From: Robert Klemme
- Re: Ruby Basics / define met;hod
- From: Chinna Karuppan
- Ruby Basics / define met;hod
- Prev by Date: Re: Cloning a module and isolating it from the clone
- Next by Date: Re: the value in ensure block is not returned
- Previous by thread: Re: Ruby Basics / define met;hod
- Next by thread: the value in ensure block is not returned
- Index(es):
Relevant Pages
|