Mystifier
1/21/2005 1:34:00 PM
By going with C++ convention, currently @vars are protected, new ones will
be private. Right?
Mystifier
-----Original Message-----
From: dblack@wobblini [mailto:dblack@wobblini] On Behalf Of David A. Black
Sent: Friday, January 21, 2005 6:42 PM
To: ruby-talk ML
Subject: Re: Protected instance variables
Hi --
On Fri, 21 Jan 2005, Mystifier wrote:
> Hi,
>
> I read somewhere @_ will be used to represent protected instance
variables.
> What will be the scope of it.
My understanding is that they'll be module/class-scoped:
module M
def a
@_var = 1
end
end
class C
include M
def b
puts @_var
end
end
c = C.new
c.a
c.b # nil
I could be getting it wrong, though.
Also I believe that Matz hasn't decided whether it will be @_var or
@var. If the latter, then @_var would be for non-protected ones. My
hatred of extra punctuation is such that I would rather see them all
behave the same way (whatever it is) and be @var.
David
--
David A. Black
dblack@wobblini.net