Garry's Mod Wiki

pairs

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: 29ms

Session 0
DB GetPage 4
Generate Html 2
SaveChanges 13
Render Body 0
Render Sidebar 8