I
Iñaki Baz Castillo
Hi, I'd like to extend Hash class [] and []=3D methods in order to find a k=
ey=20
with case insensitive. This is:
=2D The actual Hash [] behaviour:
{"a"=3D>1,"b"=3D>2}["a"]
=3D> 1
{"a"=3D>1,"b"=3D>2}["A"]
=3D> nil
=2D The beaviour I look for:
{"a"=3D>1,"b"=3D>2}["a"]
=3D> 1
{"a"=3D>1,"b"=3D>2}["A"]
=3D> 1
But I can't modify [] method since it's Ruby core written in C:
=2D---------------------
VALUE
rb_hash_aref(hash, key)
VALUE hash, key;
{
VALUE val;
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
return rb_funcall(hash, id_default, 1, key);
}
return val;
}
=2D----------------------
How could I do it?
=2D-=20
I=C3=B1aki Baz Castillo
ey=20
with case insensitive. This is:
=2D The actual Hash [] behaviour:
{"a"=3D>1,"b"=3D>2}["a"]
=3D> 1
{"a"=3D>1,"b"=3D>2}["A"]
=3D> nil
=2D The beaviour I look for:
{"a"=3D>1,"b"=3D>2}["a"]
=3D> 1
{"a"=3D>1,"b"=3D>2}["A"]
=3D> 1
But I can't modify [] method since it's Ruby core written in C:
=2D---------------------
VALUE
rb_hash_aref(hash, key)
VALUE hash, key;
{
VALUE val;
if (!st_lookup(RHASH(hash)->tbl, key, &val)) {
return rb_funcall(hash, id_default, 1, key);
}
return val;
}
=2D----------------------
How could I do it?
=2D-=20
I=C3=B1aki Baz Castillo