Reputation: 395
According to the documentation, the function identical
checks whether two references are to the same object.
With that in mind, I don't understand why the following is the case:
int a = 1;
int b = 1;
print(identical(a, b)); // prints 'true'
Map c = { 1: 'y' };
Map d = { 1: 'y' };
print(identical(c, d)); // prints 'false'
I'd expect both calls to return 'false'.
Upvotes: 1
Views: 202
Reputation: 4554
identical compares references. a
and b
are references to a compile time literal 1
. Thus they are identical.
Upvotes: 2