|
|
|
|
|
by hisham_hm
1977 days ago
|
|
> So is l[len(l) - 1] == l[-1] in those contexts? No, because Lua is 1-based :) The last element is l[#l] (#l is "length of l"). Negative indices aren't really used in arrays, but are used in the string library, so given s = "hello"; s:sub(1,4) gives you "hell" and s:sub(-2,-1) gives you "lo". |
|
Basically, some things are more "natural" with 1-based counting, but some aren't.