Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #2971
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | 7stud -- <bbxx789_05ss@yahoo.com> |
| Newsgroups | comp.lang.ruby |
| Subject | instance_eval trickiness |
| Date | Fri, 15 Apr 2011 13:53:15 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 32 |
| Message-ID | <1bebb61ab4b8db7e05ec21c3f0b37a93@ruby-forum.com> (permalink) |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1302893611 36578 65.111.164.187 (15 Apr 2011 18:53:31 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Fri, 15 Apr 2011 18:53:31 +0000 (UTC) |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 381664 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <1bebb61ab4b8db7e05ec21c3f0b37a93@ruby-forum.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:2971 |
Show key headers only | View raw
Hi, I think instance_eval() is the trickiest of the eval's to understand. "Metaprogramming Ruby" says there are two concepts that you have to be aware of: 1) which object is self 2) which object is the current class Unlike self, there is no keyword that you can print out that tells you what the current class is. The most obvious indicator of what the current class is in your code is the 'class' keyword: class Dog ... end Between 'class' and 'end' the current class is Dog. At times it is important to know what the current class is because def's attach themselves to the current class. In the case of classes like Dog, inside the Dog class (but outside of any method definitions)it so happens that self and the current class are the same: class Dog #in here the current class is Dog puts self #=> Dog end -- Posted via http://www.ruby-forum.com/.
Back to comp.lang.ruby | Previous | Next | Find similar | Unroll thread
instance_eval trickiness 7stud -- <bbxx789_05ss@yahoo.com> - 2011-04-15 13:53 -0500
csiph-web