From: Jeff Wood Date: 2005-09-29T09:14:46+09:00 Subject: Re: Python to Ruby: Two puzzlements... Actually everything you do in ruby has a receiving object reference under the covers... if you do obj.method you are explicitly setting the receiving object ... Other wise, it's always implicitly SELF And to mess with your brain a bit more, you can do an instance_eval where you set self to some other object ... class Blah attr_accessor: a end obj1 = Blah.new obj2 = Blah.new obj1.instance_eval do @a = 1 end obj2.instance_eval do @a = 2 end ... remember that there are actually VERY few keywords in Ruby.... everything else is a method on some object in the system ... when you define functions in a script outside of a class definition, self is still there for a silent single instance of Object that wraps everything in your script. ... once you get used to that, it's pretty happy sailing. Welcome to Ruby ... we hope you enjoy the ride. j. On 9/28/05, Elf M. Sternberg wrote: > James Edward Gray II writes: > > > On Sep 28, 2005, at 1:46 PM, Elf M. Sternberg wrote: > > > Welcome to Ruby. Hopefully it will stop baffling you very soon now. ;) > > Thank you. One can only hope. > > > > The first is from > > > http://redhanded.hobix.com/bits/hyperextended.html, and my question is > > > about the 'extend' keyword there. Where does that came from? In what > > > object is it defined? > > > It is defined in Object. > > I guess I'm just surprised by the implicit reference. In Python > (and Perl, to an even greater if more obscure degree) extensions like > that are quite explicit. It is not immediately obvious to me that > 'extend' is a part of Object. > > It's all a matter of familiarity. I wouldn't be surprised to > see something more like self.extend(...), but the 'extend ...' just > seems rather unattached. > > For what it's worth, this is making some *very* cobwebbed > portions of my brain think, "Y'know, this looks like ObjC (circa 1996, > via Webobjects) on drugs." > > > > I'm guessing that the "%r" and "%w" are the ruby equivalents of perl's > > > qr{} and qw{} constructs > > > > Bingo. > > That part's easy enough. Thanks! > > Elf > > -- "http://ruby-lang.org -- do you ruby?" Jeff Wood