Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Rubinius alone succeeds where others fail.

class String
  alias old_hash hash
  def hash
    self.downcase.old_hash
  end
  
  def eql?(other)
    self.hash == other.hash
  end
end

require 'test/unit'

class TestCaseInsensitiveHashAccess < Test::Unit::TestCase
  def test_case_insensitivity
    h = {'a' => 1, 'B' => 'buzz'}
    assert_equal(1, h['A'])
    assert_equal('buzz', h['b'])
  end
end