I didn't know you could do that (seems I learn something new about Ruby
everyday)!  That's pretty handy, however to be useful it should be at the
top of the class versus at the bottom (after the methods are declared).  The
following generates an error ...

class Test
  protected :foo

  def foo
  end

end

>ruby Test.rb
Test.rb:2:in `protected': undefined method `foo' for class `Test'
(NameError)
        from Test.rb:2

I understand why I get the error (I'm declaring a method before it's seen)
but logically, the scope declaration should appear (IMO) at the top of the
class along with class properties and attr_* statements.  Why can I declare
an attribute readable/writeable/both before it's declared but not methods?
It seems like the interpreter should peek ahead for methods too.  *shrug*

-Dave


-----Original Message-----
From: James Edward Gray II [mailto:james / grayproductions.net] 
Sent: Monday, March 27, 2006 9:00 AM
To: ruby-talk ML
Subject: Re: Areal noob question

On Mar 27, 2006, at 7:52 AM, Jim Weirich wrote:

> David Ishmael wrote:
>> I'm still learning Ruby (so don't flame me too hard here), but  
>> some of
>> the
>> programming paradigms I've grown accustomed to such as inline scope
>> declarations and type hinting are missed (at least by me).
>>
>> protected foo( SomeObject o ) { ... }
>>
>> In that one line I can tell you that the method is protected and
>> requires
>> SomeObject to be passed to it.  Versus Ruby's:
>>
>> protected
>>
>> def foo( o )
>>     ...
>> end
>
> Can't help much with the protected issue, but

Sure we can!  ;)  Use the other protected method declaration syntax:

def foo...

def bar...

protected :foo, :bar

Hope that helps.

James Edward Gray II