This seems like a bug...
class Foo
def to_int
3
end
end
x = Foo.new
p x.object_id
y = "hello"
y[x] = "t"
...prints out...
76260
test.rb:10:in `[]=': index 76260 out of string (IndexError)
from test.rb:10
So it appears that even though to_int is defined on my Foo class, aref
tries to use the object ID to index into the string. It should use the
result of to_int, no?
- Charlie