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 #   ww  w  . j  a  v  a2s  . co  m
x.delete("a") 
p x

Result

Related Topics