From: Farhad Farzaneh Date: 2010-02-19T06:44:21+09:00 Subject: Re: Ruby conditionals subtlety? Ryan Davis wrote: > On Feb 18, 2010, at 11:49 , Farhad Farzaneh wrote: > >> Hi, >> >> Anyone know why thse two forms of "unless" behave differently? >> >>> irb >> irb(main):001:0> foo = true unless defined?(foo) >> => nil >> irb(main):002:0> unless defined?(fooo) ; fooo = true ; end >> => true > > oddity in the way the code is parsed: > > % echo "foo = true unless defined?(foo)" | parse_tree_show > s(:if, s(:defined, s(:lvar, :foo)), nil, s(:lasgn, :foo, s(:true))) > > % echo "unless defined?(fooo) ; fooo = true ; end" | parse_tree_show > s(:if, s(:defined, s(:call, nil, :fooo, s(:arglist))), nil, s(:lasgn, > :fooo, s(:true))) Cool, any chance you could give a short description for those of us that have never really thought about the parser or used parse_tree_show? thx -- Posted via http://www.ruby-forum.com/.