From: Phrogz Date: 2007-04-03T06:35:07+09:00 Subject: Re: New presentation on Ruby On Apr 2, 3:20 pm, Ilan Berci wrote: > Slide 22) If "top level functions" are "private" methods of class > Object, there would be no way to call them without a receiver which is > simply not the case I think you have that backwards. Private methods *cannot* be called with an explicit receiver: def foo; "bar"; end puts Object.private_methods.grep( /foo/ ) #=> foo puts foo #=> bar puts self.foo #=> tmp.rb:4: private method `foo' called for main:Object (NoMethodError) class Foo def go1 secret_word end def go2 self.secret_word end private def secret_word "bird" end end f = Foo.new p f.go1 #=> "bird" p f.go2 #=> tmp.rb:7:in `go2': private method `secret_word' called for # (NoMethodError) > Slide 24) Point about attributes only allowed to be defined within their > class definition is wrong. In ruby I can define one almost anywhere > with Object::instance_variable_set or Module::module_eval. > > Slide 26) Who are you to say what "private" means. Each class has their > own definition and either could be viewed as the truth. Given that, I > can still access private methods in a class by going through send() so > your statement is not correct IMO both of the above slides are correct. Just because Ruby lets you do crazy things (break encapsulation by reaching 'inside' via instance_eval or send) doesn't mean that it doesn't exist and function well. > Slide 53) Subjective to the point of insanity.. Now now, be nice :)