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 www.  j  av  a  2  s  .c  o  m
x.delete("a") 
p x

Result

Related Topics