Environment

gettenv

Returns the environment table associated with a thread.

Syntax

gettenv(thread: thread): table
Aliases getstateenv

Arguments

NameTypeDescription
threadthreadThread to inspect or run inside.

Returns

NameTypeDescription
environmenttableEnvironment table for the selected context.

Description

Returns the environment table associated with a thread.

Call it with 1 parameter(s): thread. The argument table explains which values are required and which ones only refine the behavior.

It returns environment (table). Use the returns table to separate successful values from nil results and recoverable errors.

Example

Example call with placeholder values.

local result = gettenv(coroutine.running())
print(result)