Merge pull request #38795 from Calinou/doc-array-dictionary-reference

Document that Dictionary is always passed as reference
This commit is contained in:
Max Hilbrunner 2020-05-17 20:30:42 +02:00 committed by GitHub
commit ea8d9c5288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -20,7 +20,7 @@
var array2 = [3, "Four"] var array2 = [3, "Four"]
print(array1 + array2) # ["One", 2, 3, "Four"] print(array1 + array2) # ["One", 2, 3, "Four"]
[/codeblock] [/codeblock]
Arrays are always passed by reference. [b]Note:[/b] Arrays are always passed by reference. To get a copy of an array which can be modified independently of the original array, use [method duplicate].
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>

View File

@ -7,6 +7,7 @@
Dictionary type. Associative container which contains values referenced by unique keys. Dictionaries are composed of pairs of keys (which must be unique) and values. Dictionaries will preserve the insertion order when adding elements, even though this may not be reflected when printing the dictionary. In other programming languages, this data structure is sometimes referred to as an hash map or associative array. Dictionary type. Associative container which contains values referenced by unique keys. Dictionaries are composed of pairs of keys (which must be unique) and values. Dictionaries will preserve the insertion order when adding elements, even though this may not be reflected when printing the dictionary. In other programming languages, this data structure is sometimes referred to as an hash map or associative array.
You can define a dictionary by placing a comma-separated list of [code]key: value[/code] pairs in curly braces [code]{}[/code]. You can define a dictionary by placing a comma-separated list of [code]key: value[/code] pairs in curly braces [code]{}[/code].
Erasing elements while iterating over them [b]is not supported[/b] and will result in undefined behavior. Erasing elements while iterating over them [b]is not supported[/b] and will result in undefined behavior.
[b]Note:[/b] Dictionaries are always passed by reference. To get a copy of a dictionary which can be modified independently of the original dictionary, use [method duplicate].
Creating a dictionary: Creating a dictionary:
[codeblock] [codeblock]
var my_dir = {} # Creates an empty dictionary. var my_dir = {} # Creates an empty dictionary.