class Foo
def title
"Oh hai."
end
def buggy
puts title
if false
title = 'Oh noes!'
end
puts title
end
end
Foo.new.buggy
This code outputs:
Oh hai.
nil
Isn’t it odd that the variable being created in an if-false block is still being created and set to nil? Hopefully this is fixed in Ruby 1.9.