On Wed, Mar 12, 2008 at 12:11 PM, Stefan Lang
<perfectly.normal.hacker / gmail.com> 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:0x2ae813c @bar="Baba">
 foo.instance_eval {remove_instance_variable :@bar } #=> "Baba"
 foo #=> #<Foo:0x2ae813c> @bar is removed