[MacRuby-devel] [MacRuby] #549: Class variables are not initialised properly.
MacRuby
ruby-noreply at macosforge.org
Mon Jan 11 09:34:19 PST 2010
#549: Class variables are not initialised properly.
-------------------------------------+--------------------------------------
Reporter: sorin.ionescu@… | Owner: lsansonetti@…
Type: defect | Status: new
Priority: blocker | Milestone: MacRuby 0.5
Component: MacRuby | Keywords: class, instance
-------------------------------------+--------------------------------------
The mime-types gem has a class and an instance interface. The class
interface uses an instance of itself. However, it doesn’t work in MacRuby.
It does not seem to be initialised properly. I have included in a sample
code with the expected behaviour. Changing @__types__ to @@__types__ will
not fix it.
#!/usr/bin/env macruby
class Test
def initialize()
@foo = true
end
def add(something)
puts "Is foo nil: #{@foo.nil?}"
end
@__types__ = self.new()
def self.add(something)
@__types__.add(something)
end
end
t = Test.new
t.add(3)
Test.add(4)
Output (MacRuby 0.5)
Is foo nil: false
Is foo nil: true
Expected (Ruby 1.9.1/1.8.7)
Is foo nil: false
Is foo nil: false
--
Ticket URL: <http://www.macruby.org/trac/ticket/549>
MacRuby <http://macruby.org/>
More information about the MacRuby-devel
mailing list