Hey guys,

This is my first message on the list - I actually just moved to Sydney. :)

As for declaring the methods private, as Andrew pointed out, you can also do
it this way:

def my_private_method;
  #do stuff
end
private :my_private_method

I personally don't like it but at least you don't have the problem of all
methods after that being private.

I wrote a post back in February where I discussed this very issue and hacked
an experimental syntax for private methods into the interpreter:
http://www.leonardoborges.com/writings/2010/02/03/hacking-rubys-syntax/

I wish something similar would get into Ruby's core.


Cheers,
Leonardo Borges
www.leonardoborges.com


On Sun, Apr 25, 2010 at 4:00 AM, Simon Macneall <[email protected]> wrote:

> yes, but that then makes any method declared after the 'private' string
> private. Which means that method declarations aren't self contained, you
> need to know what has gone before in the file.
>
> so
>
> class Foo
>  def bar
>    :bar
>  end
> private
>  def baz
>    :baz
>  end
>
>  def this_is_private_too
>    :doh
>  end
> end
>
> Simon
>
>
>
> On Sun, 25 Apr 2010 09:49:25 +0800, Nicholas Jefferson <
> [email protected]> wrote:
>
>  One minor glitch that annoys me is that you can't declare a method
>>> private in the method definition itself.
>>>
>>
>> class Foo
>>   def bar
>>     :bar
>>   end
>> private
>>   def baz
>>     :baz
>>   end
>> end
>>
>> foo = Foo.new
>> p foo.bar
>> p foo.baz
>>
>> Thanks,
>>
>> Nicholas
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rails-oceania%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to