[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

where nested methods go ?

Pietro Maggi

9/23/2007 12:23:00 PM

Hi,
I'm very new to ruby, so please forgive me if my question seems somehow
silly.
I typed the following code:

class Myclass
def m1
def m2
puts "m2"
end
end
end

a = Myclass.new
a.m1
a.m2

b = Myclass.new
b.m2

which gives the following output:

m1
m2

While it is clear to me where the m1 method goes (that is: in the class
object referred by Myclass constant) I'm a bit confused on why also m2
is in Myclass class object!

I need some clarifications about it...

tahnks!
Pietro
--
Posted via http://www.ruby-....

2 Answers

Tim Hunter

9/23/2007 12:42:00 PM

0

Pietro Maggi wrote:

> While it is clear to me where the m1 method goes (that is: in the class
> object referred by Myclass constant) I'm a bit confused on why also m2
> is in Myclass class object!
>

This question was thoroughly discussed in this thread:

http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/8f4f9b54e86486b5/b9b44e4fc8d19429?lnk=gst&q=nested+methods&rnum=2#b9b44e...

--
RMagick OS X Installer [http://rubyforge.org/project...]
RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?for...]
RMagick Installation FAQ [http://rmagick.rubyforge.org/instal...]

Pietro Maggi

9/23/2007 12:55:00 PM

0

Thanks! I will have a look at that!
Pietro

Tim Hunter wrote:
> Pietro Maggi wrote:
>
>> While it is clear to me where the m1 method goes (that is: in the class
>> object referred by Myclass constant) I'm a bit confused on why also m2
>> is in Myclass class object!
>>
>
> This question was thoroughly discussed in this thread:
>
> http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/8f4f9b54e86486b5/b9b44e4fc8d19429?lnk=gst&q=nested+methods&rnum=2#b9b44e...

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