On Sat, Feb 22, 2003 at 06:05:23AM +0900, Brian Candler wrote: > On Sat, Feb 22, 2003 at 05:00:44AM +0900, Bill Dueber wrote: > > I'm new to Ruby, and want to know what The Best Way To Do It is... > > > > I've been playing around with a simple Tree class, trying to get a handle > > on 'yield' and iterators in general, which my Perl knowledge doesn't help > > with so much... > > A couple of asides: > > > class Tree > > include Enumerable > > @data # The data > > @kids # The (optional) children > > You don't need to put @data or @kids; the assignments in 'initialize' are > all you need. (It doesn't make much sense to refer to instance variables > outside of a method) This is the class instance variable police. Freeze! Keine Bewegung! ;-) It is a meaningful thing to do but it's not what he wants anyway. For one legitimate use of class instance variables, see http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/62292 -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com (It is an old Debian tradition to leave at least twice a year ...) -- Sven Rudolph