On Feb 4, 2008, at 13:19 , Karl von Laudermann wrote: > On Feb 4, 4:01 pm, "gr... / spray.se" <gr... / spray.se> wrote: >> Hi, >> >> While debugging some ruby-code, I found a mis-typed construct like >> the >> following, >> which looks like a syntax error to me, >> but when you run it in irb it evaluates to nil and does NOT raise an >> error: >> >> x = def >> puts xyz >> end >> >> (where xyz is undefined) >> Anyone can explain what the above code means to ruby? > > I believe that it is being interpreted as defining an empty method > like so: > > def puts(xyz) > end > > and assigning to x the result of the call to "def". Yup: 504 % echo "x = def puts xyz end " | parse_tree_show -:2: warning: void value expression s(:lasgn, :x, s(:defn, :puts, s(:scope, s(:block, s(:args, :xyz), s(:nil)))))