From: Dave Thomas Date: 2000-12-31T00:40:08+09:00 Subject: [ruby-talk:8357] Re: Stuck on p40 of Programming Ruby John Rubinubi writes: > I did get the above example to work, though. Thanks. I still haven't > managed to get any form like the example in the book to work, though. I > mean the [] without the associated Module or Class name. It's OK, though. > I'll press on and figure it will all come together sometime. Try something like class Offset def initialize(n) @n = n end def [](offset) @n + offset end end o = Offset.new(10) o[0] #=> 10 o[99] #=> 109 o[-12] #=> -2 Regards Dave