From: Robert Dober Date: 2006-09-21T20:38:30+09:00 Subject: Re: access specifiers ------=_Part_4589_32608541.1158838707232 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 9/21/06, Sourav wrote: > > Hi, > I am new to Ruby and after progamming in several other languages, I am > really enjoying the fun of Ruby. I had question regarding the access > specifiers in Ruby; suppose the following two classes, > > class C1 > private > def aMethod > "I am a method" > end > end > > class C2 < C1 > public :aMethod > end > > In C1, aMethod was private, but in C2 it became public... so this way, > any private method of a class can be converted to public methods. So > then what is the use of having them (private methods) in the first > place at all! In C++, there is a rule that, an object (data or Sorry for being blunt, as a matter of fact I am not, it is just the timing of the response :( The sooner you forget about C++ the sooner you will get Ruby. function) of lower access-specifier can be upgraded to higher > acc-specifier but the reverse is not true. Should it not also be > implemented in Ruby? This is a very reasonable point, it is all about "enabeling" and "controlling" approach. Ruby happens to be very liberal and of course there are downs. (so comparin= g with C++ will give you lots of headaches I am afraifd) For most of the part we - those who love ruby - think that the ups outweight the downs. The example you have given is not really anything unusual for the ruby philosophy. Look at this e.g a =3D Object.new class << a private def hello puts "Hi there" end end a.send :hello I'm a beginner, so please let me know if I'm missing anything. Thanks > in advance. Welcome to the big adventure ? Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_4589_32608541.1158838707232--