Lua's Length Operator

Lua includes a length operator # which (in theory) returns the number of items contained in the value to which it is applied. However, it is frankly a bit wonky and can give unexpected results if used outside of a fairly narrow range of applications.

Part of the wonkiness is that it behaves differently depending on the type it is acting upon. For this reason, we look at how it behavior with each of the following types: