From: Alia Amin Date: 2002-07-02T18:36:17+09:00 Subject: Re: package protected methods Hi, irb(main):001:0> class Aclass irb(main):002:1> protected irb(main):003:1> def faclass1 irb(main):004:2> puts "faclass1" irb(main):005:2> end irb(main):006:1> public irb(main):007:1> def faclass2 irb(main):008:2> puts "faclass2" irb(main):009:2> end irb(main):010:1> end nil irb(main):011:0> inst = Aclass.new # irb(main):012:0> inst.faclass2 faclass2 nil irb(main):013:0> inst.faclass1 NameError: protected method `faclass1' called for # from (irb):13 regards, alia Matthias Veit wrote: >Hi, > >is there a possibility to gain a visibility like java's >package protection construct: >classes in the same module (or class) can access methods, >that are not visible from otside the package. > >Eg: >module A > class B > protected > def foo > end > end > > class C > def foo > B.new.foo > end > end >end > >A::C.new.foo #no error >A::B.new.foo #raise error > >I don't want to use the send method, so the only solution at >the moment is simply to not use the protected modifier. >The problem seems to me so common, that there must be a >solution I did not realized - but which? > >Best regads, >Matthias > >_________________________________________________________ >Do You Yahoo!? >Get your free @yahoo.com address at http://mail.yahoo.com > >