Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Typechecking with number keys?

can you assign types with number keys? not just a generic array, but also checking for order. for example, I have a particular array that's three long in a certain order. easy enough to write.

local arr1 = {1, "string", true}
local arr2 = {
	[1] = 1,
	[2] = "string",
	[3] = true
}

types, not so much

-- none of these work
type Tarr1 = {
	1: number
	2: string
	3: boolean
}

type Tarr2 = {
	[1]: number
	[2]: string
	[3]: boolean
}

type Tarr3 = {
	[number]: number
	[number]: string
	[number]: boolean
}

-- desperate here
type Tarr4 = {
	number: number
	number: string
	number: boolean
}

yes, I could turn it into a dictionary, but it defeats the point :/

1 answer

would this work?

type something = {
	number,
	string,
	boolean
}

1 comment

0

tried that before, no unfortunately :(

This discussion is preserved as it was. New answers, comments, and votes are closed.