Ruby - Hash Element Deleting

Introduction

Deleting hash elements is easy with the delete method.

All you do is pass in a key as a parameter, and the element is removed:

Demo

x = { "a" => 1, "b" => 2 } 
p x # from  w  w  w . jav  a2s.  com
x.delete("a") 
p x

Result

Related Topics