Garry's Mod Wiki

pairs

function, table, any pairs( table tab )

Description

Returns an iterator function(next) for a for loop that will return the values of the specified table in an arbitrary order.

For alphabetical key order use SortedPairs.

For alphabetical value order use SortedPairsByValue.

Arguments

1 table tab
The table to iterate over

Returns

1 function
The iterator (next)
2 table
The table being iterated over
3 any
nil (for the constructor)

Example

Iterates through all players on the server and prints their names.

for k, v in pairs( player.GetAll() ) do print( v:Nick() ) end
Output: A list of players in console.

Page Links


Special Pages


Wikis

?

Render Time: 35ms

DB GetPage 3
Generate Html 10
SaveChanges (1) 8
Render Body 0
Render Sidebar 11