From: Thomas Wieczorek Date: 2008-03-12T20:39:59+09:00 Subject: Re: undefine instance var & [] (three questions) On Wed, Mar 12, 2008 at 12:11 PM, Stefan Lang wrote: > > > 3) Is there a way to undefine @variable. I assign nil to them, but in > > to_yaml output they are still there (even if empty). Is there way to > > undefine them? > > "ri instance_variable" reveals Object#remove_instance_variable. > I found it there and tried a bit in irb: class Foo attr :bar def initialize @bar = "Baba" end end foo = Foo.new #=> # foo.instance_eval {remove_instance_variable :@bar } #=> "Baba" foo #=> # @bar is removed