Many people have been arguing with me with this kind of code:
print(#{"1", "2", "3"})
The output:
3
Now, people argue that the octothorpe (#) returns the number of values in a table, and it does. They're correct.
The other day, I met somebody who thought they could return the number of values in a DICTIONARY:
print(#["oof"])
He, of course, was wrong and got an error. But he then argued that...
print(#"oof")
...is the same as...
print(string.len("oof"))
Both lines return the number 3. However, I argued that the octothorpe works on both strings and tables, and I was right (well, duh).
The very next thing he argues about is this:
print(#{"a", [3] = "b"})
He thinks that the output is 5, because he claimed that "Since there are 2 strings and 1 number in square brackets, the output is 5." BUT, the output is actually ONE. Why? The octothorpe returns only the last bracket key for tables starting with 1. Because [3] is the only bracket value in the table, the output is 1 and not 5.
So how exactly does this work? I really want this guy to stop annoying me.

1 comment
Non-numerical indices do not count towards the length of a table.