ForEach iterates over this table of elements, yielding each in turn to a given function.
(cb func(LValue, LValue))
| 324 | |
| 325 | // ForEach iterates over this table of elements, yielding each in turn to a given function. |
| 326 | func (tb *LTable) ForEach(cb func(LValue, LValue)) { |
| 327 | if tb.array != nil { |
| 328 | for i, v := range tb.array { |
| 329 | if v != LNil { |
| 330 | cb(LNumber(i+1), v) |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | if tb.strdict != nil { |
| 335 | for k, v := range tb.strdict { |
| 336 | if v != LNil { |
| 337 | cb(LString(k), v) |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | if tb.dict != nil { |
| 342 | for k, v := range tb.dict { |
| 343 | if v != LNil { |
| 344 | cb(k, v) |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | // This function is equivalent to lua_next ( http://www.lua.org/manual/5.1/manual.html#lua_next ). |
| 351 | func (tb *LTable) Next(key LValue) (LValue, LValue) { |