stupid hash update experiments in ruby

/ Published in: Ruby
Save to your folder(s)

Copy this code and paste it in your HTML
  1. h1 = {'1'=>'a', '2'=>'b', '3'=>'c', '4'=>'z'}
  2. h2 = {'4'=>'e'}
  3. puts h1.inspect
  4. # => {"1"=>"a", "2"=>"b", "3"=>"c", "4"=>"z"}
  5. h1.update(h2)
  6. puts h1.inspect
  7. # => {"1"=>"a", "2"=>"b", "3"=>"c", "4"=>"e"}

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.