Skip to content

Dictionaries are compared by reference with ==, unlike Arrays which are compared by value #27615

Closed
@AlexDarigan

Description

Godot 3.1

In Python (for example), if you were to compare Dictionaries they would evaluate to true as long as key-value pairs were the same. In GDScript, Dictionary comparison is based on a reference to the same Dictionary Object.

var x = {0: 10}
var y = x
print(x == y) // Outputs true
var x = {0: 10}
var y = {0: 10}
print(x == y) // Outputs false

Is this the intended behaviour?

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions