Delete from hash : include « Hash « Ruby
- Ruby
- Hash
- include
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
Related examples in the same category