summaryrefslogtreecommitdiff
path: root/modules/gdscript/tests/scripts/analyzer/features/property_inline.gd
blob: 23eb011b237939eadd0f8f5533a695345b8bab28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Untyped inline property
var prop1:
	get:
		return prop1
	set(value):
		prop1 = value

# Typed inline property
var prop2 : int:
	get:
		return prop2
	set(value):
		prop2 = value

# Typed inline property with default value
var prop3 : int = 1:
	get:
		return prop3
	set(value):
		prop3 = value

# Typed inline property with backing variable
var _prop4 : int = 2
var prop4: int:
	get:
		return _prop4
	set(value):
		_prop4 = value

func test():
	print(prop1)
	print(prop2)
	print(prop3)
	print(prop4)

	print()

	prop1 = 1
	prop2 = 2
	prop3 = 3
	prop4 = 4

	print(prop1)
	print(prop2)
	print(prop3)
	print(prop4)