I’m having a little trouble with generic types
I have all the logic for types worked out except when it come to actually said types.
For example, in this case I have a function foo that takes a generic type:
local function foo<T>(bar: T) ... end
however when I try to call foo and assign T:
foo<string>("some string")
Roblox does not except this as valid code.
Am I doing something wrong with my syntax?
Perhaps something is going over my head here, but this is not something I have ever seen done?
You are correct that typechecking occurs using the : character, E.g. function abc(var: string) would allow you to get autocomplete suggestions (and make reading the code easier) for var, knowing that it is a string.
If bar is always a string, I would suggest setting it up as follows: