Would doing obj: Object = {}
and then calling typeof
on it give Object
?
no.
A Object in Lua is a table.
local table = {}
calling typeof(obj) will just error
If this is what you mean! Haha
No it’ll return table
instead as it’s a table.
I have to ask, where did you get this statement from?
My bad. (The way you phrase it looks like you meant this)
No, I am basing on her code, in Lua that wouldn’t work;
obj: Object = {} -- syntax error
properly:
local Object = {}
No it will just return the actual datatype of the value rather than the custom type you have created.
type Object = {}
local Obj: Object = {}
print(typeof(Obj))
Will output table
. You should have no reason to check the type of variables if you’re using type safety properly though.
It is indeed a syntax error; but the fix is not removing the type entirely. Just define obj
as local.
local obj: Object = {}
3 Likes