What exactly would this be doing?

Just a small Question,

I’m not exactly sure what this would be doing, I randomly made it while creating a ModuleScript which I was using to Handle Important Data, But I dont exactly understand what it would do to my code, or if its useful at all, and I was wondering if someone would explain to help?

Sorry if this is vague.

--!strict

type levelData = {{ -- new type? idk what its called
	num: number;
	active: boolean;
}}

local no  = false -- i was just bored with these
local yes = true

local levels: levelData = { -- table as new type?
	{num = 15, active = no};
	{num = 30, active = no};
	{num = 45, active = no};
}

Thanks.

1 Like

This adds type autocompletion to your code. It basically just makes it easier to type things out.

This tells the script that the levels table has the pre-defined type information provided in the levelData type. This can also be dynamically infered by the type checker as well.

-- Example
type FileTypes = "png" | "jpeg" | "jpg" | "webp"

local function insertFileType(fileType: FileTypes)
  --...
end

If you typed this into the Roblox Studio editor, the editor will give you autocomplete options for the fileType parameter (similar to game:GetService or Instance:FindFirstChild).

(Posted this a bit earlier than I was planning)

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.