File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,19 @@ class Pair<F, S> {
2121 final S second;
2222
2323 const Pair (this .first, this .second);
24+ @override
25+ bool operator == (Object other) =>
26+ identical (this , other) ||
27+ other is Pair <F , S > &&
28+ runtimeType == other.runtimeType &&
29+ first == other.first &&
30+ second == other.second;
31+
32+ @override
33+ int get hashCode => first.hashCode ^ second.hashCode;
34+
35+ @override
36+ String toString () => 'Pair($first , $second )' ;
2437}
2538
2639/// create pair for given elements first and second.
Original file line number Diff line number Diff line change @@ -10,5 +10,12 @@ void main() {
1010 expect ("first" , result.first);
1111 expect (1 , result.second);
1212 });
13+
14+ test ("pair equal" , () {
15+ var pair1 = pairOf ("first" , 2 );
16+ var pair2 = pairOf ("first" , 2 );
17+
18+ assert (pair1 == pair2);
19+ });
1320 });
1421}
You can’t perform that action at this time.
0 commit comments