Skip to content

Instantly share code, notes, and snippets.

@aashish
Last active December 13, 2015 16:48
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 aashish/4942434 to your computer and use it in GitHub Desktop.
Save aashish/4942434 to your computer and use it in GitHub Desktop.
class Dictionary
attr_accessor :entries
attr_accessor :keywords
def initialize
@x = Hash.new
end
def entries
@x
end
def add(hash)
hash.class == String ? @x[hash] = nil : @x.merge!(hash)
end
def keywords
@x.keys
end
end
d = Dictionary.new
d.add({'fish' => 'aquatic animal'})
d.add('tiger')
puts d.keywords
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment