On Feb 18, 2010, at 13:44 , Farhad Farzaneh wrote: > Ryan Davis wrote: >> On Feb 18, 2010, at 11:49 , Farhad Farzaneh wrote: >>=20 >>> Hi, >>>=20 >>> Anyone know why thse two forms of "unless" behave differently? >>>=20 >>>> irb >>> irb(main):001:0> foo =3D true unless defined?(foo) >>> =3D> nil >>> irb(main):002:0> unless defined?(fooo) ; fooo =3D true ; end >>> =3D> true >>=20 >> oddity in the way the code is parsed: >>=20 >> % echo "foo =3D true unless defined?(foo)" | parse_tree_show >> s(:if, s(:defined, s(:lvar, :foo)), nil, s(:lasgn, :foo, s(:true))) >>=20 >> % echo "unless defined?(fooo) ; fooo =3D true ; end" | = parse_tree_show >> s(:if, s(:defined, s(:call, nil, :fooo, s(:arglist))), nil, s(:lasgn,=20= >> :fooo, s(:true))) >=20 > Cool, any chance you could give a short description for those of us = that=20 > have never really thought about the parser or used parse_tree_show? Your latter code snippet treats "fooo" in defined? as a method call. = This is because the assignment inside the conditional hasn't been parsed = yet, and hasn't affected the lookup tables. The former doesn't have this problem because the body of the conditional = is parsed first.