[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: How to print the content of Table/
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 7 May 2012 09:17:43 +0200
2012/5/7 Emeka <firstname.lastname@example.org>:
> A global variable (not a function) that holds the global environment
> (see §2.2). Lua itself does not use this variable; changing its value does
> not affect any environment, nor vice-versa.
> The above is still confusing, what is it used for? And why is it there at
>> > However, I have a question, what is _G? And, why is it empty when I try
>> > it on the shell?
In Lua 5.2, _ENV can point to many different tables depending on what
the program is doing. _G is just another name for the original _ENV.
To go back to the original _ENV, you just say _ENV=_G.
It is not empty in the shell, but since it has no numeric keys,
#_G comes out zero.