lua-users home
lua-l archive

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


Am 07.08.2016 um 17:41 schröbte Soni L.:

How about

table.len = function(t)
  assert(type(t) == "table", "bad argument #1 to 'len' (table expected,
got "..type(t)..")")
  return #t
end

Most of the table library now can work on userdata with suitable `__index`/`__newindex`/`__len` metamethods defined, so this seems like a step in the wrong direction. Maybe we should get rid of (or deprecate) `string.len` instead. It is superfluous since we have the length operator.

Philipp