Hi,

I was reading this http://www.rubycentral.com/book/ref_c_hash.html#Hash.shift

and I wondered how this could be useful. I must be missing something.

I tried this

ahash = {"a" => "apple","b"=> "boat","c" =>"car", "dog" => "zebra",
"elephant" => "yak"}
p ahash #=>{"a" => "apple","b"=> "boat","c" =>"car","elephant" =>
"yak", "dog" => "zebra"}
p ahash.shift #=>["a", "apple"]
p ahash.shift #=>["b", "boat"]
p ahash.shift #=>["c", "car"]
p ahash.shift #=>["elephant", "yak"]
p ahash.shift #=>["dog", "zebra"]

Since the order of a hash is not guaranteed, you do not know what you
are shifting at any given time. Is this right?
If you just wanted to shift everything you could use Hash#each.

What am I missing?

Harry

-- 

A Look into Japanese Ruby List in English
http://www.kakueki.com/