The top example is casting the child as a CardUI so the engine knows its a CardUI and will also help provide the auto-complete functions when scripting, etc.
The bottom example is just doing a type check. So you aren’t actually type casting, but just doing a check on its type. So if the child is of type CardUI then continue running whatever is in the if block.
Oh I see. So the editor can help me with the functions if I tell it to expect it to be type CardUI. What happens if one of the children (say I added a Sprite2D later for some flair or something). Will this crash my game since I’m not first checking if the child is a CardUI before type casting it?
EDIT: I don’t know why I asked when I could just try it.
It does crash if I did that so I assume the best way to hand this would be to check the type before casting it correct?
In C# you get back a null if you cast to an invalid type. I guess it is same in gdscript? So if you know it can be more than one type just check for nulls too, or do the is check. In C# you can cast with is, which is quite nice since you use it in an if statement and will thus not encounter the null exception if (child is CarUI cui) cui.DoSomething();