Project

General

Profile

Bug #1469 ยป classvars.rb

biteme (Kenneth Ballou), 05/15/2009 04:26 AM

 
class Holder
@@var = 99
def Holder.var=(val)
@@var = val
end
def Holder.read_var
@@var
end
def var
@@var
end
end

@@var = "top level variable"

a = Holder.new
puts "a.var: #{a.var}"
Holder.var = 123
puts "a.var: #{a.var}"

def a.get_var
@@var
end

puts "a.get_var: #{a.get_var}"
puts "@@var: #{@@var}"
puts "Holder.read_var: #{Holder.read_var}"
    (1-1/1)