So i made a Previous post about type checking and i was wrong at some points im not here to discuss this today but to tell you about my new founding.
so i figure this out by mistake but apperently if you make a function & function it will create this when you try and index it:
<1/2> Foo(Arg)->()
I tried to upload a photo but did not work i hope you understand what i mean by that if not then:
You see some functions have 1 argument but different let me show you.
--If this arg 1 is number it will return number
--else arg 1 is boolean it will return boolean
function Foo(arg)
if (type(arg)=="number") then
return (arg == 1) and 1 or 0
elseif (arg == "boolean") then
return not arg
end
print(Foo(1)) --prints 0
print(Foo(false)) -- prints true
end
You may say so what?
Well when you index the function a gray ui appears showing you the Name of the
Function comments and details of the function in roblox studio.
If you just leave it so it will show you:
Foo(arg:a):number
if you use a common typechecking and set the arg to (number|boolean)
then you get:
Foo(arg:number|boolean):number|boolean
But how does roblox or native function have the fancy text details why their functions
can be commented like that and we cannot comment ours?
Good question i don’t know but i know this
function Foo(arg)
if (type(arg) == "number") then
return (arg == 1) and 1 or 0
elseif (type(arg) == "boolean") then
return not arg
end
end
local Foo = Foo :: ((arg:number)->number)&(boolean)->(boolean)
Now if you index Foo it will have the Secret technique
<1/2> Foo(arg:number):number
and if you click any of those buttons
<2/2> Foo(arg:boolean):boolean
So why did i post this?
Why is there stuff like this who are not documented anywhere in both luau documentation and roblox documentation?
And how much more secrets are there that we have not uncovered.
Or mabey im just a rookie and its common knowlage
if anyone knows how to comment on your functions properly and document them
please tell me i don’t know how!
I KNOW HOW TO COMMENT
what i mean is this
in javascript they use
/**@Param … Arg1*/
in lua they use
—@Param … Arg1
thats the issue that im trying to solve.
You have reached the end thank you!