The shift
method of a hash is used to return the first hash entry of a hash.
hash.shift
This method does not take any parameters.
This method returns a 2-element array that contains the removed key and value.
# create hashesh1 = {one: 1, two: 2, three: 3}h2 = {name: "okwudili", stack: "ruby"}h3 = {"foo": 0, "bar": 1}h4 = {M:"Mango", A: "Apple", B: "Banana"}# use the shift methodputs "#{h1.shift}"puts "#{h2.shift}"puts "#{h3.shift}"puts "#{h4.shift}"