Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 2
    \$\begingroup\$ Does _ENV=5 work? If so, it's one character shorter. \$\endgroup\$ Commented Oct 22, 2015 at 0:54
  • 8
    \$\begingroup\$ @immibis True, but this is a popularity contest, not a code length contest. PS - Trust you to home in on the Lua answer. \$\endgroup\$
    – Pharap
    Commented Oct 22, 2015 at 1:08
  • \$\begingroup\$ +1 for Lua. Doesn't $_G=nil$ do more or less the same as well? \$\endgroup\$
    – Doddy
    Commented Oct 23, 2015 at 7:19
  • \$\begingroup\$ @Doddy Nope, because _G is just a copy of _ENV you can use to look up variables and stuff like that - it isn't actually the environment. You could, however, do _G=nil and then set the environment to _G, and that would have the same effect. \$\endgroup\$
    – Nico A
    Commented Oct 23, 2015 at 10:48
  • 1
    \$\begingroup\$ Not entirely true. If you have a backup somewhere in local variable, you can restore it. And you can still define local variables and even call string-related functions! \$\endgroup\$ Commented Jun 10, 2019 at 19:57