[Question] Using an array/table in a certain way...

I am working on a code and I’d like to check if the following is possible:


//defined like so:
	pl.pMenuPage={
		1=hook.Run("function1"),
		2=hook.Run("function2"),
	}

//then used like so:
if pl.pMenuPage[1] then end

Cause in C language when you do:


if(array*)//either 1/0 its true then it launches.

You can do:


local table = 
{
    1 = function() myfunction() otherfunction() end,
    2 = function() myfunction2() otherfunction() end,
}


table[ 1 ]()

No need for hook.Run()

hook.Run runs a hook but I’m not sure if you want to run a hook or a function since you’ve named them ‘function1’ and ‘function2’



function function1()
    return true
end

function function2()
    return true
end

pl.pMenuPage = {
    function1, 
    function2
}
if(pl.pMenuPage[1]()) then 
    
end


or



pl.pMenuPage = {
    'hook1',
    'hook2'
}

hook.Run(pl.pMenuPage[1]) 


for a hook

He’s not comparing them though?

You don’t even know what he’s trying to do, so I’m not sure how you can declare what he’s doing is unnecessary.

Ye, sorry about that.
I’ve only read half of it on my phone.