lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


A problem this I can foresee, at least for variables, is that if fred is a number #fred will return the abs of that number. However if fred is a table then #fred will return it's length (with the usual caveats)

I can envision a whole new class of errors where someone uses a scalar variable where they should have used a table and check the (supposed) tables length with the # only to find that it is not a table after all

if #fred > 0 then
  print("We have " .. #fred .. " records to process")
  for k, v in pairs(fred) do
    print(k, v)
  end
end

Here the error is "bad argument #1 to 'for iterator' (table expected, got number)"

Not sure that having an alias for abs is really worth the pain