y
has been defined in if block, it will be nil
. If that is removed, it gives an error: "undefined local variable or method `y' for main:Object".
if false
y = 'hi'
end
puts y
Why can the variables in if-block initialize?
y
has been defined in if block, it will be nil
. If that is removed, it gives an error: "undefined local variable or method `y' for main:Object".
if false
y = 'hi'
end
puts y
Why can the variables in if-block initialize?