Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Class-level readers and writers
dblack
11/30/2003 11:11:00 AM
1 Answer
T. Onoma
11/30/2003 4:44:00 PM
0
On Sunday 30 November 2003 12:11 pm, David A. Black wrote:
> I don't think so.
>
> [...]
>
> > Or is that class local variable? Cause I'm not understand how @@a "will
> > behave like today's class instance variables without the need of ``class
> > attribute accessors''."
>
> Matz's description is:
>
> * class variables will be local to the class/module
> * if you need to access class variables from outside,
> define accessors
>
> (See <
http://www.rubyist.net/~matz/slides/rc2003/mgp0002...
.)
>
> So class vars will be able to do what they currently can't do, namely
> maintain state on a truly per-class basis (as opposed to
> per-hierarchy). The difference between them and a class's instance
> variables, as I understand it, will be that the class variables are
> visible from instances of the class.
Thanks David,
I'm actually starting to get dizzy 8-o. It would help, I think, if we lay
this down cold for all to understand. Could you fix the following yummy
class, to the best of your knowledge:
class ClassVariableSoup
class_local_var # scope is ?
def variables
local_var # scope is method
@class_instance_var # scope is instance/ancestry
@_local_class_instance_var # scope is instance
@@class_var # scope is class+instance/ancestry
@@_local_class_var # scope is class+instance
# others ?
end
$global_var # scope if everywhere
end
Much Obliged,
-t0
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Class-level readers and writers
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password