Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | molesallegiance |
Hi. I just stumble on new cases where I want to assign dictionary to default__dictionary. But after asking in Godot discord, some nice guy teach me that what I am doing is referencing dictionary not assign or duplicate the default_dictionary.
The question is. Is there a way to know like in c++ where “&” is using for referencing?
Below is the case that I stumble upon:
var a: int = 2;
var b: int = a;
b = 0;
print(a);
print(b);
# The output is 2 and 0
var a_dict: Dictionary = {
"animals" : "pig"
};
var b_dict: Dictionary = a_dict;
b_dict.animals = "baboon";
b_dict = a_dict;
print(a_dict);
print(b_dict);
# The output is {animals:baboon} and {animals:baboon}
# What I want is {animals:pig} and {animals:baboon}
Just a suggestion: the ends of each line don’t need to have a semicolon on them. Happy coding!
Ertain | 2022-10-16 22:57
Yeah… It’s a habit… Our professor make us use semicolon in every single line when we start programming, even though it’s a python. I guess she want’s to make our transition to other language easier.
molesallegiance | 2022-10-17 00:17