What does # mean in Lua? -
i have seen character '#' being added front of variables lot in lua, wondering does? have found example of being used here.
-- sort ais in currentlevel table.sort(level.ais, function(a,b) return a.y < b.y end) local curaiindex = 1 local maxaiindex = #level.ais = 1,#currentlevel+maxaiindex if level.ais[curaiindex].y+sprites.monster:getheight() < currentlevel[i].lowery table.insert(currentlevel, i, level.ais[curaiindex]) curaiindex = curaiindex + 1 if curaiindex > maxaiindex break end end end
apologies if has been asked, i've searched around on internet lot haven't seem have found answer. in advance!
that length operator:
the length operator denoted unary operator #. length of string number of bytes (that is, usual meaning of string length when each character 1 byte).
the length of table t defined integer index n such t[n] not nil , t[n+1] nil; moreover, if t[1] nil, n can zero. regular array, non-nil values 1 given n, length n, index of last value. if array has "holes" (that is, nil values between other non-nil values), #t can of indices directly precedes nil value (that is, may consider such nil value end of array).
Comments
Post a Comment