Hi --

On Mon, 24 Mar 2003, Greg McIntyre wrote:

> Thanks to all of you who answered and cleared up some of my perceptions
> about Python. As a result I've put together some slides introducing Ruby
> to Python programmers (hopefully without any misinformation!).
>
> This is a 30 minute lecture on Ruby, aimed at 3rd year university
> students who have just learnt Python. Feedback welcome.
>
> http://www.cse.unsw.edu.au/~gregm/secret/ssdi/lectures/

Overall it looks good to me (though I say that as a Python
know-nothing -- mainly focusing on the Ruby stuff).  There's one
example I think is misleading:

  Private attribute x of class A in Ruby:

  class A
    def initialize; @x = 0; end
  end
  a = A.new; a.x = 1   # exception!

The problem here is that there is no method x, private or otherwise.
The example implies that having an instance variable causes a private
reader method to spring into being.  In fact, there's no special
relationship between instance variables and methods with the same
names.  The attr_* methods are handy but they're basically just typing
shortcuts.

(This might also have implications for the equivalence you draw between
"self.attribute" in Python and "@attribute" in Ruby, but I'm not sure
exactly what's going on on the Python side there.)


David

-- 
David Alan Black
home: dblack / superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav