#Function argument
16 messages · Page 1 of 1 (latest)
well, first thing is you can't have default values before non-default values
I know that sorry about it had to be fast
There are no keywored args like in python
and the... what Dex said
what you can do is use a dictionary instead
Do I have to give it every value then?
func function(args:Dictionary) -> void:
var arg1 = args.get("arg1", default_value)
var arg2 = args.get("arg2", default_value)
if not "arg3" in args:
push_error("arg3 is needed")
return
...
so you can just do function({"arg3": your_value})
Thanks its pretty good solution
see the official docs for more dictionary magic
Godot Engine documentation
A built-in data structure that holds key-value pairs. Description: Dictionaries are associative containers that contain values referenced by unique keys. Dictionaries will preserve the insertion or...
get(key, default) is rather amazing magic
Will look into it thanks again
