解决方法
这是一个很好的问题.它与Ruby中变量的范围有关.
这是一个post by Matz on the Ruby bug tracker关于这个:
local variable scope determined up to down,left to right. So a local variable first assigned in the condition of if modifier is not effective in the left side if body. It’s a spec.