Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Liemaeu |
I just found out that there is “setget” in GDScript. But what is the advantage of using it?
At the moment I write getter and setter functions (e.g. in my global script) like this (like in learned in school with Java):
var test = 0
func set_test(var new_test):
test = new_test
func get_test():
return test
And then I can call e.g. Global.set_test(1)
and Global.get_test()
from my other scripts.
But what is the advantage/difference of using:
var test = 0 setget set_test,get_test
func set_test(var new_test):
test = new_test
func get_test():
return test