From: ts Date: 2001-09-25T22:20:48+09:00 Subject: [ruby-talk:21670] Re: Help understanding self ... >>>>> "P" == Phil Mitchell writes: P> I'm defining a simple class that extends Hash. The code below P> works. What I don't understand is why I can't replace P> the line: "self[key] = key" with "[key] = key"? If I leave out the P> "self", I get a parse error. Why? Well, because `[something]' is valid only as a rhs. If ruby always interpret `[something]' as `self[something]' how do you make this work ? a = [1, 2] # create an Array In some case `a = self[1, 2]' can give an error pigeon% ruby -e 'a = self[1, 2]' -e:1: undefined method `[]' for # (NameError) pigeon% Guy Decoux