Ruby/Hash/member

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Checking for the presence of keys in a hash: fast

h = { :a => 1, :b => 2 }
h.key?(:a)       # true: :a is a key in h
h.has_key?(:b)   # true: has_key? is a synonym for key?
h.include?(:c)   # false: include? is another synonym
h.member?(:d)    # false: member? is yet another synonym