where nested methods go ?

P

Pietro Maggi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top