Ruby/Hash/include

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

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

Delete from hash

h = {:a=>1, :b=>2}
h[:a] = nil      # h now holds {:a=> nil, :b=>2 }
h.include? :a    # => true
h.delete :b      # => 2: returns deleted value: h now holds {:a=>nil}
h.include? :b    # => false
h.delete :b      # => nil: key not found