Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Module Eval Syntax
John W. Long
1/26/2006 8:15:00 PM
>> class MyModule; end
=> nil
>> MyModule.class_variables
=> []
>> MyModule.module_eval do
?> @@test = true
>> end
=> true
>> @@test
=> true
>> MyModule.module_eval "@@weird = true"
=> true
>> @@weird
NameError: uninitialized class variable @@weird in Object
from (irb):8
>> MyModule.class_variables
=> ["@@weird", "@@test"]
>> Object.class_variables
=> ["@@test"]
What in the world is going on here? Why does the block syntax eval
differently than the string syntax? And why does @@test get defined on
both MyModule and Object?
--
John Long
http://wiseheart...
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Module Eval Syntax
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