File: enum_without_default_value.gd

package info (click to toggle)
godot 4.4.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 229,428 kB
  • sloc: cpp: 1,657,504; ansic: 186,969; xml: 153,923; cs: 36,104; java: 29,122; python: 15,230; javascript: 6,211; yacc: 4,115; pascal: 818; objc: 459; sh: 459; makefile: 109
file content (23 lines) | stat: -rw-r--r-- 551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
enum HasZero { A = 0, B = 1 }
enum HasNoZero { A = 1, B = 2 }
var has_zero: HasZero # No warning, because the default `0` is valid.
var has_no_zero: HasNoZero # Warning, because there is no `0` in the enum.


func test():
	print(has_zero)
	print(has_no_zero)


# GH-94634. A parameter is either mandatory or has a default value.
func test_no_exec(param: HasNoZero) -> void:
	print(param)

	# Loop iterator always has a value.
	for i: HasNoZero in HasNoZero.values():
		print(i)

	match param:
		# Pattern bind always has a value.
		var x:
			print(x)