@Cvieyra2test said in CVExtra -- Super Module Script (DEVELOPMENT FORUM):
However, question, what is the third argument you have provided there,
It is known as "0" on the Lua wiki for ipairs, is it like the starting position or somethin'?
ipairs is for traversing the array part of a table. It returns 0 since it adds 1 and Lua's arrays start at 1.
rawequal in too many unnecessary places. There is very rarely a need for it.
To bypass the
__eq metamethod. It's just a new habit of mine. Semicolons and my conditional expressions in parenthesis is also unnecessary but you don't complain about that?
What if the metatable has its own metatable which has an
__eq field? Hmm?
You would not use it like this. I'll quote the PIL:
next(t, k), where
k is a key of the table
t, returns a next key in the table, in an arbitrary order. (It returns also the value associated with that key, as a second return value.) The call
next(t, nil) returns a first pair. When there are no more pairs,
You don't need to use
nil, you can just return
next, mt. But the PIL returns nil as well so why not
ipairs, I'll go in a bit more depth.
In that link, the
iter function is called passing the argument of
0. This is the
i parameter. It is incremented by 1. The next call will be
iter(a, 1) and will then be
a, and so on, until a nil value is encountered.
pairs (again x2), that is also why some people put
next directly instead of calling
pairs. This adds a negligible performance boost. Use
pairs. It's clearer. Micro optimisations are never a good argument. You rarely need to use
next, both inside or outside a generic for loop.