View Single Post
08-05-14, 10:30 AM   #8
Sharparam
A Flamescale Wyrmkin
 
Sharparam's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 102
Originally Posted by Resike View Post
However it's intresting, because you would expect that the pairs call would throw a nil error but it doesn't.
Because there is no nil error in the call. {nil, nil} doesn't evaluate to nil, it evaluates to an empty table: {}. But since it has no values there is nothing to iterate over and the loop is "skipped".

Code:
> type({nil, nil})
'table'
> for _,_ in pairs(nil) do end
[string "local"]:1: bad argument #1 to 'pairs' (table expected, got nil)
> for _,_ in pairs({}) do end
> -- No output

Last edited by Sharparam : 08-05-14 at 10:34 AM. Reason: More examples
  Reply With Quote