4.3
Hi all
I’m trying the following output in Gdscript:
extends Node2D
var points: int = 100
var result = points >= 100 if “gold” else “silver”
func _ready() → void:
print("result = " + str(result))
Output true → i want = gold
4.3
Hi all
I’m trying the following output in Gdscript:
extends Node2D
var points: int = 100
var result = points >= 100 if “gold” else “silver”
func _ready() → void:
print("result = " + str(result))
Output true → i want = gold
ternarys are true_val if condition else false_val
in python and gdscript, try this
var result = "gold" if points >= 100 else "silver"
Though using a ternary on a class member initialization is strange, it will only run once and before @export
ed variables, so do not expect more from it than “gold”