MCPcopy Index your code
hub / github.com/yuin/gopher-lua / Append

Method Append

table.go:66–84  ·  view source on GitHub ↗

Append appends a given LValue to this LTable.

(value LValue)

Source from the content-addressed store, hash-verified

64
65// Append appends a given LValue to this LTable.
66func (tb *LTable) Append(value LValue) {
67 if value == LNil {
68 return
69 }
70 if tb.array == nil {
71 tb.array = make([]LValue, 0, defaultArrayCap)
72 }
73 if len(tb.array) == 0 || tb.array[len(tb.array)-1] != LNil {
74 tb.array = append(tb.array, value)
75 } else {
76 i := len(tb.array) - 2
77 for ; i >= 0; i-- {
78 if tb.array[i] != LNil {
79 break
80 }
81 }
82 tb.array[i+1] = value
83 }
84}
85
86// Insert inserts a given LValue at position `i` in this table.
87func (tb *LTable) Insert(i int, value LValue) {

Callers 8

TestTableLenFunction · 0.80
TestTableAppendFunction · 0.80
TestTableInsertFunction · 0.80
TestTableMaxNFunction · 0.80
TestTableRemoveFunction · 0.80
TestTableForEachFunction · 0.80
tableInsertFunction · 0.80
TestObjLenFunction · 0.80

Calls

no outgoing calls

Tested by 7

TestTableLenFunction · 0.64
TestTableAppendFunction · 0.64
TestTableInsertFunction · 0.64
TestTableMaxNFunction · 0.64
TestTableRemoveFunction · 0.64
TestTableForEachFunction · 0.64
TestObjLenFunction · 0.64