Created
August 2, 2022 11:24
-
-
Save iapicca/94b8a1223d48a5dd7cb43e9e2cee50cb to your computer and use it in GitHub Desktop.
weird equality issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<int> integersUntil(int limit) => [for (var i = 0; i < limit; i++) i]; | |
| class Foo { | |
| final List<int> bar; | |
| final List<int> baz; | |
| const Foo(this.bar, this.baz); | |
| @override | |
| bool operator ==(Object other) => other is Foo && other.hashCode == hashCode; | |
| @override | |
| int get hashCode => Object.hash(bar, baz); | |
| } | |
| void main() { | |
| final foo1 = Foo( | |
| integersUntil(10), | |
| integersUntil(100), | |
| ); | |
| final foo2 = Foo( | |
| integersUntil(10), | |
| integersUntil(100), | |
| ); | |
| print(foo1 == foo2); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment