From: "Hakusa@..." Date: 2007-06-29T16:10:02+09:00 Subject: Re: Calling private method in ruby On Jun 29, 2:31 am, Alin Popa wrote: > 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 > > -- > Posted viahttp://www.ruby-forum.com/. Maybe the fact that you have to use send will at least make you appreciate that the method IS private in a real world scenario. But to be honest, I think that making methods private is usually unnecessary to begin with, but it does help with something I've forgotten about. And because you're getting at the method through another method, it'll take longer to act on it; not excruciatingly longer, though.