When is $SAFE reset?


#1

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 everyeval’?

Thanks in advance,

Bertram