[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

When is $SAFE reset?

Bertram Scharpf

1/19/2006 12:55:00 AM

Hi,

irb(main):001:0> begin ; $SAFE=2 ; end ; puts $SAFE
2
irb(main):002:0> puts $SAFE
0
irb(main):003:0> def s ; $SAFE=2 ; end ; s ; puts $SAFE
2
irb(main):004:0> puts $SAFE
0
irb(main):005:0> eval "$SAFE=2; puts $SAFE" ; puts $SAFE
2
0
rb(main):007:0> eval "$SAFE=1; eval '$SAFE=2; puts $SAFE' ; puts $SAFE" ; puts $SAFE
2
1
0

Obviously, $SAFE will be reset after `eval' expressions have
completed. Are there (besides threads) other cases where
$SAFE is reset? And if not: why will it be reset after
every `eval'?

Thanks in advance,

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-...