From: "Bennett, Patrick" Date: 2002-08-13T07:35:00+09:00 Subject: RE: Q) about singleton methods and access control Christoph wrote in message >>"Bennett, Patrick" wrote in message >> This is what I'd "like" to do: >> class A >> >> def initialize() >> @varInternalOnly = 'test' >> end >> >> def A.createSpecialA() >> testObj = A.new >> testObj.internalHelperMethod() >internalHelperMethod is an ``instance method'' not a Class method >(see below). Maybe I'm missing something here, but.... I called it from an instance. You saw the 'testObj = A.new' - right? ;> >Anyway, as the short term fix you can >simply write > > testObj.send(:internalHelperMethod) That works(!)... but why? (scratching head) Why does send bypass access control? >Note that C++ static (class) method are quite different to Ruby's class methods I never expected them to be the same - I was just curious why a fairly 'obvious' (at least to me) situation like being able to have a static method create instances of the classes it's defined in and access private methods wasn't supported in Ruby. Cheers, Patrick Bennett