“LUA -Liste Append” Code-Antworten

Lua Array Artikel hinzufügen

local tbl = {}
table.insert(tbl, "Hello World")
Matteo

LUA -Liste Append

-- One can append an element to the end of an array with the function table.insert.
-- table.insert takes three arguments, the table, the position, and the value to insert.
-- By default the position is equal to the length of the table + 1, in other words it will append it to the end.

local t = {};

table.insert(t, "a"); -- Insert "a" at position 1.
table.insert(t, "c"); -- Insert "c" at position 2.
table.insert(t, 2, "b"); -- Insert "b" at position 2, therefore pushing the "c" to position 3.

for i,v in ipairs(t) do
	print(i, v); -- 1 "a", 2 "b", 3 "c".
end
[Nn]uclear\s[Tt]he\s[Nn]oob.*

Lua Array Artikel hinzufügen

local tbl = {}
tbl[1] = "Hello World"
Matteo

Ähnliche Antworten wie “LUA -Liste Append”

Fragen ähnlich wie “LUA -Liste Append”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen