initial commit, 4.5 stable
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
Some checks failed
🔗 GHA / 📊 Static checks (push) Has been cancelled
🔗 GHA / 🤖 Android (push) Has been cancelled
🔗 GHA / 🍏 iOS (push) Has been cancelled
🔗 GHA / 🐧 Linux (push) Has been cancelled
🔗 GHA / 🍎 macOS (push) Has been cancelled
🔗 GHA / 🏁 Windows (push) Has been cancelled
🔗 GHA / 🌐 Web (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
# 4.0+ replacement for `setget`:
|
||||
var _backing: int = 0
|
||||
var property:
|
||||
get:
|
||||
return _backing + 1000
|
||||
set(value):
|
||||
_backing = value - 1000
|
||||
|
||||
var property_2:
|
||||
get(): # Allow parentheses.
|
||||
return 123
|
||||
|
||||
func test():
|
||||
print("Not using self:")
|
||||
print(property)
|
||||
print(_backing)
|
||||
property = 5000
|
||||
print(property)
|
||||
print(_backing)
|
||||
_backing = -50
|
||||
print(property)
|
||||
print(_backing)
|
||||
property = 5000
|
||||
print(property)
|
||||
print(_backing)
|
||||
|
||||
# In Godot 4.0 and later, using `self` no longer makes a difference for
|
||||
# getter/setter execution in GDScript.
|
||||
print("Using self:")
|
||||
print(self.property)
|
||||
print(self._backing)
|
||||
self.property = 5000
|
||||
print(self.property)
|
||||
print(self._backing)
|
||||
self._backing = -50
|
||||
print(self.property)
|
||||
print(self._backing)
|
||||
self.property = 5000
|
||||
print(self.property)
|
||||
print(self._backing)
|
||||
|
||||
print(property_2)
|
Reference in New Issue
Block a user