S
Sourav
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
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?
I'm a beginner, so please let me know if I'm missing anything. Thanks
in advance.
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
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?
I'm a beginner, so please let me know if I'm missing anything. Thanks
in advance.