|
Now that I think about it, there is a problem with the example but I don't think we agree on where the problem is. Let me explain:
I expect the following statements to throw the same error... for node in traverse(nil) do ... end for node in traverse(8008135) do ... end for node in traverse("string") do ... endThat seems natural to me. The error message could be made friendlier, but I don't see why nil needs to be a special case. The problem, in my opinion, is the following line...
list = nilFor this example, I think that an empty list is better represented by an empty table than a nil. Of course, a non-empty list can still be terminated by a nil or an empty table.
Mike Taj Khattra wrote:
The two statements are equivalent. Re-read section 3.3.=(function() if not nil then return nil else return 1729 end end)()nil=(not nil and nil or 1729)1729