From: Rich Kilmer Date: 2002-01-01T11:11:13+09:00 Subject: [ruby-talk:29926] Re: Ruby/Python: Software Engineering > -----Original Message----- > From: Bjorn Pettersen [mailto:BPettersen@NAREX.com] > Sent: Monday, December 31, 2001 6:09 PM > To: ruby-talk ML > Subject: [ruby-talk:29910] Re: Ruby/Python: Software Engineering > > > > From: Kyle Cordes [mailto:kyle@kylecordes.com] > > > > "Mathieu Bouchard" wrote in message > > news:Pine.LNX.4.21.0112311600250.3187-100000@bartok... > > > > > > Enforced indention (you indent your own code I bet) > > > > > That's a nice feature to save writing "end" all the time. But not > > having > > > to write "self" all the time is much more important to me. > > > > That's always been a mystery to me... I enjoy Python's > > terseness that comes from using indentation to describe > > blocks, but it doesn't seem to reconcile with the (IMHO) > > sillyness of writing self everywhere. > > You need some way of disambiguating nested classes (how does Ruby do > this btw?): > > class Outer: > def method1(self): pass > def method2(self): > class Inner: > def innerMeth1(this): pass > def innerMeth2(this): > self.method1() > this.innerMeth1() In this example is class Inner defined in the method2 body? In Ruby you can do this: class Outer def method1 end class Inner def innerMethod1 end end end but the Inner class is NOT an inner class (a la Java) but a class defined in the namespace Outer and referenced as: in = Outer::Inner.new in.innerMethod1 Now, that class does not have access to the methods on Outer (unless they are class methods like: class Outer def Outer.method1 end end Then the innerMethod1 can execute the class method as: class Inner def innerMethod1 Outer.method1 end end Or if Inner is a subclass of Outer you could do this: class Outer def method1 end class Inner < Outer def innerMethod1 method1 end end end > > Etc. > > -- bjorn >