A
Alin Popa
Hi there,
I have a little problem regarding private methods in Ruby.
I have the following case:
class MyClass
private
def my_method
puts "something from my method"
end
end
myClass = MyClass.new
begin
myClass.my_method
rescue
puts "Method cannot be called because is private"
end
myClass.send("my_method")
So, can anyone help me by explaining in a logical way, what is the point
of private methods in ruby since I can call it using "send" ?
Thanks in advance,
Alin
I have a little problem regarding private methods in Ruby.
I have the following case:
class MyClass
private
def my_method
puts "something from my method"
end
end
myClass = MyClass.new
begin
myClass.my_method
rescue
puts "Method cannot be called because is private"
end
myClass.send("my_method")
So, can anyone help me by explaining in a logical way, what is the point
of private methods in ruby since I can call it using "send" ?
Thanks in advance,
Alin