From: ts Date: 2001-07-25T15:41:02+09:00 Subject: [ruby-talk:18511] Re: Basic OO Tutorial, Ruby & Perl >>>>> "c" == clpoda writes: c> # One way to handle the case where no 'name' is provided Another way :-) c> class Animal c> def initialize(name) c> if name == "" c> @name = "an unnamed #{self.class} " c> else c> @name = name c> end c> end def initialize(name = "an unnamed #{self.class} ") @name = name end c> def speak c> print @name, " says ", sound, "\n" c> end c> end c> class Horse < Animal c> def sound; "neigh"; end c> end c> aHorse = Horse.new("") aHorse = Horse.new c> aHorse.speak c> talking = Horse.new("Mr. Ed") c> talking.speak Guy Decoux