Skip to content
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

Type casting when declaring a variable does not work #32905

Closed
dalexeev opened this issue Oct 18, 2019 · 2 comments · Fixed by #34916
Closed

Type casting when declaring a variable does not work #32905

dalexeev opened this issue Oct 18, 2019 · 2 comments · Fixed by #34916

Comments

@dalexeev
Copy link
Member

Godot version:
3.1.1.stable.official
3.2.alpha2.official

OS/device including version:
5.2.20-1-MANJARO

Issue description:

See examples:

var x = "abc"
var res: bool = x
print(res) # prints 'abc'
print(res == true) # Error: Invalid operands 'String' and 'bool' in operator '=='
var x = null
var res: String = x
print(res) # prints 'Null'
print(res.length()) # Error: Invalid call. Nonexistent function 'length' in base 'Nil'

1

It works (but the icon is wrong, by the way):

2

@fsy98
Copy link
Contributor

fsy98 commented Oct 22, 2019

If the code still have problem.I think it may the program didn't do the type casting, so try another way to do the type casting. For example convert boolen into string: .toString()

@dalexeev
Copy link
Member Author

dalexeev commented Oct 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants