#Type checking a key in a module dictionary?
53 messages · Page 1 of 1 (latest)
i dont really understand probally because im not very good at scripting but couldnt you do a table and store the type inside the table? in the module
Do you mean making a custom class?
Not sure if you can use typechecking using them
I mean you should be able to technically speaking
you can
Then what’s the issue?
I can do this
local var: mytype = "hello
Is there a way to assign it to variables inside arrays? Like this:
module.var: mytype = "hello"
^ that doesn't work
This will just error
Quite sure you’ll have to create them in that class
the issue isn't custom types but rather assigning a type to a module variable
this won't work either
What does the error say?
nothing it's just underlined in red
Hovering over red underlined parts should show the error
which means that it will error
Oh right
It thinks you’re calling a function
How do you typecast a function again… fuck I forgot
function myfunc() : string
return "hello"
end
No the function call
Wait that was the same? I must quickly say
I hate typechecking past just the params of functions
yeah
The issue is it's not a local variable but rather a key in a dictionary
Type checking a key in a module dictionary?
The only way I can think of is like this:
That does carry over the type into module.Standard but I have to create that as a local variable and then assign it as a key
Wait standard is not a function?
I taught it was a function returning a metatable
nono it's just a dictionary
That actually confuses me more
Wdym?
Need what?
i find type checking useless
It prevents errors when working with custom classes
my code doesnt error
especially in cases like this where it would take me forever to find the error only to find I misspelled one of the keys
then you've never used custom classes
Have you ever used metatables before?
wrong..
yeah