On 19 jun, 07:48, "Robert Dober" <robert.do... / gmail.com> wrote:
>
> Let us see?
>
> Which assignment Matz?
>
> irb(main):001:0> def x;1 end
> => nil
> irb(main):002:0> if false then
> irb(main):003:1* def x; 2 end
> irb(main):004:1> end
> => nil
> irb(main):005:0> x
> => 1
> irb(main):006:0> def y; 1 end
> => nil
> irb(main):007:0> if false
> irb(main):008:1> undef y
> irb(main):009:1> end
> => nil
> irb(main):010:0> y
> => 1
>
> Surely the statements inside if are not executed.
>

No, but they are parsed. And identifiers are made local variables at
parse time, not at execution time. So if you have an assignment
anywhere, even in a place that will never actually execute, the
identifier used in the assignment will be considered a local variable
by the interpreter.

Christophe.