Replies: 1 comment
-
Teal does not do type inference with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This example causes a type error:
You can obviously fix it like this:
However if you use
t
several times in the function it is a bit annoying to cast several times.This does not work:
This does but it shadows the variable:
How do you deal with things like this? In this case Teal could infer it automatically from the test, but in general it could be helpful to "persist" a cast.
I have this issue in real Lua code I am converting to Teal and the way I work around it for now is by with a sub-function like this:
Beta Was this translation helpful? Give feedback.
All reactions