Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > where nested methods go ?

Reply
Thread Tools

where nested methods go ?

 
 
Pietro Maggi
Guest
Posts: n/a
 
      09-23-2007
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-forum.com/.

 
Reply With Quote
 
 
 
 
Tim Hunter
Guest
Posts: n/a
 
      09-23-2007
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....b44e4fc8d19429

--
RMagick OS X Installer [http://rubyforge.org/projects/rmagick/]
RMagick Hints & Tips [http://rubyforge.org/forum/forum.php?forum_id=1618]
RMagick Installation FAQ [http://rmagick.rubyforge.org/install-faq.html]

 
Reply With Quote
 
 
 
 
Pietro Maggi
Guest
Posts: n/a
 
      09-23-2007
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....b44e4fc8d19429


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to find the class methods of a class, just like'methods' finds the instance methods? Kenneth McDonald Ruby 5 09-26-2008 03:09 PM
dealing with nested xml within nested xml within...... Ultrus Python 3 07-09-2007 09:00 PM
Is nested class automatically friend of class that it is nested in? request@no_spam.com C++ 5 09-25-2006 08:31 AM
Nested Vector Nester Classes are Nested in my Brain Chad E. Dollins C++ 3 11-08-2005 04:46 AM
Nested iterators (well, not nested exactly...) Russ Perry Jr Java 2 08-20-2004 06:51 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57