--bcaec553ff0c72edfd04ba961fcf Content-Type: text/plain; charset=UTF-8 Are you talking about sth. like this: b.method(:foo).owner # Dance b.method(:bar).owner # Boogy ? On Tue, Mar 6, 2012 at 11:34 AM, Ralph Shnelvar <ralphs / dos32.com> wrote: > Consider; > > - - - > > class Dance > def foo > puts "foo is executed" > 42 > end > end > > class Boogy < Dance > def bar > puts (foo.class) > end > end > > b oogy.new > > b.foo # prints "foo is executed" ... expected. > > b.bar # prints "foo is executed\nFixnum" ... not expected! > > - - - > > Let's focus on the line > puts (foo.class) > > So let's say I'm in the middle of a debugging session trying to debug the > bar method. > > I see this thing called "foo" and I want to know what it is. > > So I > puts (foo.class) > > Since everything in ruby is an object and all objects have classes, I'm > expecting to print out the class of this thing called foo. > > What happens, though is that foo gets executed (which is not what I want) > and returns 42 ... whose class is Fixnum. > > > Questions: > How can I tell what class of object foo is without executing it? > Is there a class called "Method" in the Ruby class hierarchy? > What class of object does define_method return? > > > Ralph Shnelvar > > > -- Best wishes, Jie Fan Life is a miracle. --bcaec553ff0c72edfd04ba961fcf Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Are you talking about sth. like this:<div><br></div><div>b.method(:foo).owner #=> Dance</div><div>b.method(:bar).owner #=> Boogy</div><div><br></div><div>?</div><div><br><div class="gmail_quote">On Tue, Mar 6, 2012 at 11:34 AM, Ralph Shnelvar <span dir="ltr"><ralphs / dos32.com></span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Consider;<br> <br> - - -<br> <br> class Dance<br> def foo<br> puts "foo is executed"<br> 42<br> end<br> end<br> <br> class Boogy < Dance<br> def bar<br> puts (foo.class)<br> end<br> end<br> <br> b = Boogy.new<br> <br> b.foo # prints "foo is executed" ... expected.<br> <br> b.bar # prints "foo is executed\nFixnum" ... not expected!<br> <br> - - -<br> <br> Let's focus on the line<br> puts (foo.class)<br> <br> So let's say I'm in the middle of a debugging session trying to debug the bar method.<br> <br> I see this thing called "foo" and I want to know what it is.<br> <br> So I<br> puts (foo.class)<br> <br> Since everything in ruby is an object and all objects have classes, I'mxpecting to print out the class of this thing called foo.<br> <br> What happens, though is that foo gets executed (which is not what I want) and returns 42 ... whose class is Fixnum.<br> <br> <br> Questions:<br> How can I tell what class of object foo is without executing it?<br> Is there a class called "Method" in the Ruby class hierarchy?<br> What class of object does define_method return?<br> <span class="HOEnZb"><font color="#888888"><br> <br> Ralph Shnelvar<br> <br> <br> </font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div><font face="'courier new', monospace">Best wishes,</font></div><div><font face="'courier new', monospace">Jie Fan</font></div> <div></div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><font face="'courier new', monospace">Life is a miracle.</font></blockquote> <br> </div> --bcaec553ff0c72edfd04ba961fcf--