#!/usr/bin/env ruby # This code comes from http://ruby-it.org/pages/Hash+python-like # Check the page for copyright notice and explanations >> hsh=Hash.new => {} >> hsh[0] => nil >>> hsh=dict() >>> hsh[0] Traceback (most recent call last): File "", line 1, in ? KeyError: 0 >> hsh=Hash.new { raise 'Errore!' } => {} >> hsh[0] RuntimeError: Errore! from (irb):31 from (irb):31:in `call' from (irb):32:in `default' from (irb):32:in `[]' from (irb):32 from :0 >> hsh[2] RuntimeError: Errore! from (irb):31 from (irb):31:in `call' from (irb):33:in `default' from (irb):33:in `[]' from (irb):33 from :0