Does anyone even know what are the "<>" symbols used for in functions?

So, a few months ago I was playing with lua syntax, probably thinking how it could be redone to write faster, such as “function” being “fn”, etc.

However, I noticed something weird?

For some strange reason, you can write functions with these <> symbols, with text inside, no spaces and regular characters.

function what<a,b,c,i_dont_know>(d,e,f)
	print(a,b,c) --> nil nil nil
	print(d,e,f) --> 1 2 3


Here, in the website’s syntax it looks red, In roblox studio, it doesnt look red and instead is just all white.


Thing’s like these don’t work for any reason.

what<a>(1,2,3) -- > Incomplete statement: expected assignment or a function call
whata(1,2,3) -- >  attempt to call a nil value

It seemed liked a cool feature if it was used like a variating character of a function so you could call the same functions with variating letters for different functionality, such as:

whata(1,2,3) -- > Calls the function with a and can achieve different functionality
whati_dont_know(1,2,3) -- > Same thing, different functionality

-- And for the function
function what<a,b,c,i_dont_know>(d,e,f)
	in statement do
		in <a> do
		or <b> do
		else do
			print("oh, i guess you didnt decide which letter.")

It doesn’t make much sense to me of why it wouldn’t throw a syntax error or anything. Even looked thru Lua or Luau documentation and I wasn’t able to find much about it. Why does it work and why is it there?

If anyone knows, it would be nice to know and use the feature if it’s even a feature.

1 Like

these are called type packs from luau’s type checking system.

you can read more about it here:

What is it’s main purpose? Reading it might be a way to assist type checking or referencing another type but I don’t understand it.

are you familiar with strongly typed programming languages? (like java, typescript, etc)

No, I have seen them though. I use the : sign when I’m working on my Roblox games to be able to more easily access part properties such as :BasePart

1 Like

ok then! this will come naturally to you then. a common use case is for when you wish to define a function that uses a type, but this type can vary, in other words, it depends on the argument (ie it can be a string, number, boolean, etc.)

for example:

1 Like

Hi, they’re actually called “generics”. Generics are used for specifying the type within a complex type, usually like how you declare variables and use them.

1 Like

Diamond brackets are used for generic types. Type packs are related but only in the scope of generic functions.

A generic type (also known as an algebraic type) takes in a type ‘parameter’ and is able to use it in place of (most) types. These can be used for any type-declaration.

type Array<Type> = {Type}

local Numbers: Array<number> -- {number}

A function generic acts almost like the opposite; based on the types of the function’s arguments, the type parameters become populated. This may be a little confusing, but it lets you do cool stuff.

local function Function<Type>(Parameter: Type): Type
    return Parameter

local Return = Function(1) -- number

Note that some languages like Java and TypeScript allow you to explicitly pass type arguments (like Function<number>(1)), but this is not allowed in Luau because it creates a syntax ambiguity.

Finally, type packs are a special feature in generic functions which allow you to pass a tuple of types. They look similar to a variadic, but the ellipsis is after the identifier instead of before.

local function Function<Type...>(...: Type...): Type...
	return ...

local Return = Function(1, "hello", true) -- number, string, boolean