Posted 14 March 2018 - 05:15 PM
So I was playing around with getfenv and noticed something weird:
So the script I used was this:
And the output was:
I was expecting this:
So the script I used was this:
local func
do
local inf = 1/0
local neginf = -inf
local NaN = 0/0
func = function()
print("Special numbers:")
print(inf)
print(neginf)
print(NaN)
end
end
func()
sleep(2)
print("\nReiteration:")
print(getfenv(func).inf)
print(getfenv(func).neginf)
print(getfenv(func).NaN)
sleep(2)
setfenv(func, {inf=1/0, neginf=-1/0, NaN=0/0})
print("\nOne more time:")
print(getfenv(func).inf)
print(getfenv(func).neginf)
print(getfenv(func).NaN)
And the output was:
Special numbers:
inf
-inf
nan
Reiteration:
nil
nil
nil
One more time:
inf
-inf
nan
I was expecting this:
Special numbers:
inf
-inf
nan
Reiteration:
inf
-inf
nan
One more time:
inf
-inf
nan
Why is it instead printing nil?Edited on 14 March 2018 - 04:15 PM