From: Ross Bamford Date: 2005-12-06T19:12:34+09:00 Subject: Re: getting around access control On Tue, 06 Dec 2005 07:33:10 -0000, wrote: > On Tue, 6 Dec 2005, Joel VanderWerf wrote: > >> These are probably not helpful: >> >> irb(main):012:0> c.instance_eval{ p send(:meth) } >> 42 >> => nil >> irb(main):013:0> c.instance_eval " p meth " >> 42 >> => nil >> >> The strange thing is that s/protected/private/ avoids the error: >> >> irb(main):014:0> class C >> irb(main):015:1> private >> irb(main):016:1> def m2; 43; end >> irb(main):017:1> end >> => nil >> irb(main):018:0> c.instance_eval{ p m2 } >> 43 >> >> (ruby-1.8.2, anyway) >> >> The original error (in the protected case) seem uncalled for.... > > [.. snip ..] > > that 'private' methods __are__ allowed is really strange indeed. > I actually really like Ruby's notion of private - just that you can't call the method with a receiver. When I first started with IRB I'd often look for methods using Something.methods.sort . It took me ages to realise why I was missing so many very common ones - because they're 'private' so that they can only be called on self. I think it's really flexible :) -- Ross Bamford - rosco@roscopeco.remove.co.uk "\e[1;31mL"