#!/usr/bin/ruby class A @@a = "a" # a class variable @b = "a" #a class instance variable attr_accessor :c def initialize(c) @c = c # an instance variable end class << self attr_accessor :b end def self.greeting puts @@a puts @b end end class B < A @@a = "b" @b = "b" end A.greeting #=> b a B.greeting #=> b b puts A.b puts A.new('c').c