On 18.12.2008, at 09:05 , e deleflie wrote:

ok

On Thu, Dec 18, 2008 at 2:25 PM, Einar Magnús Boson
<[email protected]> wrote:

On 18.12.2008, at 02:27 , e deleflie wrote:

class Outside
@baba = WayOutside.new()
def runTread

That does not mean what you think it does.

ok ... I'm a Java programmer so my world view is javanese.

can you quickly explain the issue? ... I cant create a class variable
in something other than the initialize method?

Etienne


Quickly: that isn't a declaration but an assignment executed in the context of the metaclass (I think..). So it becomes an instance variable of the meta class, not the class itself. These issues confuse me a bit too though.
Not so quick but from someone who seems to know what he's doing:
http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html



Try this and it'll work:

class WayOutside
def sayBang
 debug "bang!"
end
end

class Outside
def initialize
@baba = WayOutside.new()
end
def runTread
 Thread.new do
   @baba.sayBang
   loop do
     debug "testing"
     sleep (rand(30)+10)/10
   end
 end
end
end

Shoes.app do
    Outside.new.runTread
    para "testing"
end


einarmagnus





einarmagnus



Reply via email to