GDScript:match的语法糖真甜

之前写过一篇关于match的日志match语句,这几天研究某大佬的代码发现了一种match写法

使用范例
func enter(msg: Dictionary = {}) -> void:
	match msg:
		{"velocity": var v, "impulse": var i}:
			self.velocity = v + Vector3.UP*i
小结

啥也不说了,太省事了

发布了272 篇原创文章 · 获赞 134 · 访问量 8万+

猜你喜欢

转载自blog.csdn.net/hello_tute/article/details/103990118