Anonymous Anonymous - 6 months ago
183 0

Class Instance Variables Are Evil

Ruby

ClassInstVarEvilnessDemo.rb

class A
   cattr_reader :a
  @@a = 'A'
end
puts A.a
puts "============="

class B < A
  cattr_reader :a
  @@a ='B'
end
puts B.a
puts A.a
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download