Godot Version
4.4.1 (but question is general)
Question
As in the topic. What will happen when I have, for example:
var ar_int : Array[int]
var ar_str : Array = [“uno”, “two”, “drei”]
ar_int.assign(ar_str) ← what happens here? Can I get error and print it somehow??
How can I safely convert array to typed array?
What will happen in above, when I try to assign “unassignable” array?
You can use Array::is_typed() and Array::get_typed_builtin() to check the arrays prior to assignment.
Ok, but what will happen when I try to assign “unassgnable” array?
yesko
4
There will be an error and the array will be left in its previous state
Unable to convert array index 0 from "String" to "int".
Ok, can I get this error somehow? Paste it into some kind of log? Will it end program execution?
yesko
6
The error will appear in the debugger:
It will not end program execution.
I believe you can can use Logger to automatically do this, I’ve never tried it myself though:
This article also seems helpful:
Why would you want to try do that when you can check if it’s assignable?