From: Guillaume Marcais Date: 2003-05-16T22:50:26+09:00 Subject: Re: public/protected/private syntax On Thursday 15 May 2003 05:26 pm, you wrote: > Guillaume Marcais wrote: > > I tend to find the public/protected/private keywords in Ruby a little > > odd. They don't seem to fit the Ruby syntax. What about the following > > syntax (for Ruby 3.0 :)? The scope of the method would be known by the > > first caracters of its name, the same way as the scope of a variable is > > determined by $, @, @@ or nothing. So: > > > > class Test > > def method1; end # public method > > def _method2; end # protected method > > def __method3; end # private method > > end > > But, in ruby, many methods that you can use without a receiver are in > fact private methods of all objects. For example, #puts, #gsub, > #require, #fork, ... (most if not all of these are actually inherited > from Kernel). > > That means you would have to type > > __require 'mylib' > > all the time. Agreed that is not convenient. Didn't think of that one. Guillaume.