I hope this is the correct category; if not, please inform me
Reason I’m asking here is because Luau originated from Roblox, and I thought maybe someone here might have some good insight?
I’ve been snooping around on the Luau website, and I’ve found a few things that I find confusing.
I’ve been in Lua, specifically Luau, for just shy of a year, and have learned most basic concepts that you use in studio, like self, APIs, etc. However, I’m genuinely baffled by a few things, and now I’m lost as to how to proceed learning.
A good example of this would be generic type aliases:
function reverse<T>(a: {T}): {T}
local result: {T} = {}
for i = #a, 1, -1 do
table.insert(result, a[i])
end
return result
end
This syntax confuses me, and I’m not sure how I’d ever practically use it.
They also have tagged unions, which baffle me:
type Ok<T> = { type: "ok", value: T }
type Err<E> = { type: "err", error: E }
type Result<T, E> = Ok<T> | Err<E>
There’s also other stuff that kind of confuse me further, but I can’t really think of what exactly they are off the top of my head
If anyone has any clue how to explain some of the concepts on Luau.org, that’d be very nice, because man am I lost! I’ve tried reading some of what the site says, but some of it just doesn’t quite make any logic sense to me.