I don't understand what the new luau recap stuff does

Hi!
I have no clue what stuff like those do

type Point = { x: number, y: number }

and

function is_empty(param: string) => boolean

Like I’ve never heard of something like that, what do they do and why do they use " : "?

I don’t really understand the whole beta luau type checking system, like they changed 20% of the Roblox Scripting language or something.

Will this one day become a normal feature and not only beta so you have to use it?

I believe that the “:” is used to depict which data type the parameter or variable is, for example if you want something to feed into a function it needs to be the right data type.

function Add(x: number, y: number) → x + y
This would not be possible if x and y were strings.

You should look up functional programming for a better understanding of that sort of syntax and programming, as functional programming is actually an entirely different style with an entirely different set of rules to object orientated programming (which Roblox uses).

Hope this helps,
-Tom :slight_smile:

1 Like

This is a sort of pseudo-code (EDIT: not pseudo-code, just code) to help developers understand what parameters these methods/functions take and how they function without overcomplicating the explanation.

That just means that ‘Point’ only accepts an array (table) with x and y being the parameters (they both have to be numbers).

is_empty accepts a string parameter, and returns a boolean (true/false)

1 Like

This isn’t pseudocode, this is actual runnable code. It lets the linter know what types functions use and whatnot.

4 Likes

I understand type checking but I would like to repeat one of @OP’s questions: Does anyone know if this will become mandatory in the future or will we always still have the option to write scripts with weak typing?

1 Like

I doubt it would ever become mandatory due to backwards compatibility concerns.

4 Likes