IIRC, the right way to check if a table is empty is
next(mytable) == nil
As the sibling comment points to, the documentation of the # operator is complex. It returns a border which is defined as:
a border is any positive integer index present in the table
that is followed by an absent index, plus two limit cases:
zero, when index 1 is absent;
and the maximum value for an integer, when that index is present.
Note that keys that are not positive integers
do not interfere with borders.
When the table has multiple borders, the behavior is undefined.