From: Alex Young Date: 2007-08-02T07:06:07+09:00 Subject: Re: Private methods not so private? Frank Meyer wrote: > Hello, > I'm using Ruby 1.8.2 and I'm reading the book "Programming Ruby 2nd > edition". In this book they say, that Ruby implements private methods by > not allowing another receiver than "self". After reading this, I tried > the following: > > class Test > private > def print_hello > puts "Hello everyone!" > end > end > > t = Test.new > t.send( "print_hello" ) > > > This program runs just fine and prints "Hello everyone!". > > > > Is this behaviour to be expected? Yes - send trumps private. Private in Ruby is more of a guideline than a rule. The implementer is trying to tell you not to go there, but you can get around it if you really need to. -- Alex