You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's see the following code. whenever a variable is nil, it will be a function if import sh.
require('sh')
print(type(x), type(nil)) -- function, nilx=nilprint(type(x)) -- function, but x is set to be nilt= {}
x='hello'z=t[x]
print(type(t[x]), type(z)) -- nil, function, but z should be nil as usual.
I forgive the first one, since x may be set to be a function by sh, but how to explain next two?
The text was updated successfully, but these errors were encountered:
This is the ordinary logic of Lua; setting a variable to nil is the same thing as never setting it in the first place.
So there's no difference between z = nil (and z = t[x] on an empty t is just a fancy way of saying z = nil) and not setting z in the first place. In both cases, the failed lookup on _G triggers the __newindex patch, causing a shell function to be returned.
Let's see the following code. whenever a variable is nil, it will be a function if import
sh
.I forgive the first one, since x may be set to be a function by
sh
, but how to explain next two?The text was updated successfully, but these errors were encountered: