From: Tobias Reif Date: 2001-10-27T21:58:01+09:00 Subject: [ruby-talk:23619] sleeping, calling methods inside class defs ruby 1.6.3 (2001-03-19) [i386-cygwin] Hi, 1. Why is the following sleeping? It just sleeps forever; how can I achieve it that it uses the method above, not the sleep method?. ----- class Tobi def sleep print "rzzzzz..\n" end sleep end ----- 2. I know this is basic, but I don't get it: ----- class Tobi def hi print "hi!\n" end hi end ----- gives NameError: :7: undefined local variable or method `hi' for Tobi:Class ----- class Tobi def hi print "hi!\n" end self.hi end ----- gives 7: undefined method `hi' for Tobi:Class (NameError) ----- class Tobi def hi print "hi!\n" end end Tobi.new.hi ----- works; but how can I use the method inside the class? ----- class Tobi def hey print "hey!\n" end def hey_ho hey print "ho!\n" end end Tobi.new.hey_ho ----- here I can call the first method inside the second, when calling the second method from outside the class def. How to call a method inside the class def? ----- class Tobi def hey print "hey!\n" end def hey_ho hey print "ho!\n" end @hey_ho = self.hey_ho end ----- doesn't work. TIA, Tobi -- Tobias Reif http://www.pinkjuice.com/myDigitalProfile.xhtml go_to('www.ruby-lang.org').get(ruby).play.create.have_fun http://www.pinkjuice.com/ruby/