From: Joseph McDonald Date: 2000-12-08T10:40:05+09:00 Subject: [ruby-talk:6924] Re: Is there any way to undefine a variable? You an remove it if made in a module: module A Unify = 1 puts defined? Unify remove_const("Unify") # note quotes around name. puts defined? Unify end prints: constant nil regards, -joe "Steven Grady" wrote in message news:90pad3$lvc$1@agate.berkeley.edu... > I ask because Rational checks whether Unify is defined. I > can make it defined easily enough: > Unify = 1 > defined? Unify # -> "constant" > but I can't figure out how to undefine it: > undef Unify # -> NameError: undefined method 'Unify' for class > # 'Object' > > This error is not surprising, since the documentation says that undef > cancels "the method definition" -- it doesn't say anything about variable > bindings. But the question remains: how do I undefine Unify after I've > defined it? > -- > Steven > "`The glorious sunset of my heart was fading. Soon the Super Karate > Monkey Death Car would park in my space.'"