pairs

From Garry's Mod
Jump to: navigation, search
 pairs( )

Contents

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

table tab

The table to iterate over

Returns

function

The iterator (next)

Returns

table

The table being iterated over

Returns

any

nil (for the constructor)

Examples

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.
Personal tools
Navigation