Skip to content

Instantly share code, notes, and snippets.

@mleszcz
Last active May 16, 2018 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mleszcz/d6f92841920c9eda5578045b205fb307 to your computer and use it in GitHub Desktop.
Save mleszcz/d6f92841920c9eda5578045b205fb307 to your computer and use it in GitHub Desktop.
class User
attr_accessor :settings
def active?
@settings[:status] == :active
end
end
class AdminUser < User
end
basic_user = User.new
basic_user.settings = { level: 0xFACE, status: :active }
basic_user.active?
# true
admin_user = AdminUser.new
admin_user.settings = [ 0xCAFE, :active ]
admin_user.active?
# TypeError (no implicit conversion of Symbol into Integer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment