Skip to content

Instantly share code, notes, and snippets.

@corntrace
Created August 11, 2011 16:44
Show Gist options
  • Save corntrace/1140134 to your computer and use it in GitHub Desktop.
Save corntrace/1140134 to your computer and use it in GitHub Desktop.
Class variable overwrite in inheritance
class BaseKlass
cattr_accessor :map
end
class KlassA < BaseKlass
self.map = {:a => 1, :b => 2}
end
class KlassB < BaseKlass
self.map = {:c => 3, :d => 4}
end
KlassA.map # => {:c => 3, :d => 4} !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment