Uninitialized thread error with a Thread subclass

Hi. I’ve encountered this problem lately :

wally.rb :
#!/usr/bin/ruby

class Goal < Thread
def initialize
puts “i’m a Goal”
end

end

dibi = Goal.new { puts “i’m dibi” }

gives

i’m a Goal
wally.rb:10:in new': uninitialized thread - checkGoal#initialize’
(ThreadError)
from wally.rb:10

I’m running ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] on
Ubuntu 10.04. Tried purging-installing ruby, to no avail.
Upgraded to ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux] on
Ubuntu 10.10, same error.

Michel G. писал 26.01.2012 23:43:

end

dibi = Goal.new { puts “i’m dibi” }

gives

i’m a Goal
wally.rb:10:in new': uninitialized thread - checkGoal#initialize’
(ThreadError)
from wally.rb:10

Add super' call within yourinitialize’ method.

I’m running ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux] on
Ubuntu 10.04. Tried purging-installing ruby, to no avail.
Upgraded to ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-linux] on
Ubuntu 10.10, same error.

Consider upgrading to Ruby 1.9. Ruby 1.8.7 is more than 3 years old,
and it will soon be discontinued.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs