-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for comparing variables of different types #26375
Comments
Me thinking it's about type coercion: After reading again, I realise you mention something slightly different: while |
Eh, then just change the error to warning, so I can disable it. (and ofc it should return false) |
@KoBeWi You can shorten the type check (while making it faster) using the if 1 is String and 1 == "0":
pass I think it's fine the way it is, but I'm not opposed to changing it to match Python's behavior. |
This problem was basically gone when I started using types .-. |
Godot version:
3.1 beta8
Issue description:
Right now you can't compare variables of different types. To do so, you first need to use typeof of whatever to check whether they are the same type and then compare it. The type-checking step is done anyways, as comparing variables of different types results in an error. So why not, instead of giving error, just return false?
Then we could do
if 1 == "0":
(imagine 1 and "0" are variables not hard-coded values)instead of
if typeof(1) == TYPE_STRING and 1 == "0":
which both result in false, but the former is much cleaner.
The text was updated successfully, but these errors were encountered: