I want to typecheck a table value collected from functions like GetChildren.
local Children:table = workspace:GetChildren()
Roblox says table is an invalid type, which is not true:
print(type({})) > table
I want to typecheck a table value collected from functions like GetChildren.
local Children:table = workspace:GetChildren()
Roblox says table is an invalid type, which is not true:
print(type({})) > table
You annotate a value’s type as table via a table constructor.
local t : {number} = {1, 2, 3} --Array of numbers.
local t2 : {[string] : boolean} = {Key1 = true, Key2 = false} --Dictionary containing string/boolean pairs.
This does not denote dynamic GetChildren tables.
Wouldn’t it just be this?
local table: {Instance} = something:GetChildren()
GetChildren
returns an array of instances.
local t : {Instance} = workspace:GetChildren()
Is this not limited to a single instance?
Instance is the type for every child. You just have to put one class that every child may inherit.
That makes sense, thank you for clarifying.