getfenv()

Type Function
Library (globals)
Return value (varies)
Revision Release 2024.3703
Keywords getfenv, setfenv, environment, global
See also setfenv()

Overview

Returns the current environment in use by a specified Function. The first argument can be a Function or a Number that specifies the function at that stack level: level 1 is the function calling getfenv(). If the given function is not a Lua function, or if f is 0, getfenv() returns the global environment. The default for f is 1.

Syntax

getfenv( [f] )
f (optional)

Function or Number. Specifies the function at that stack level.