File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,19 @@ class Pair<F, S> {
21
21
final S second;
22
22
23
23
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 )' ;
24
37
}
25
38
26
39
/// create pair for given elements first and second.
Original file line number Diff line number Diff line change @@ -10,5 +10,12 @@ void main() {
10
10
expect ("first" , result.first);
11
11
expect (1 , result.second);
12
12
});
13
+
14
+ test ("pair equal" , () {
15
+ var pair1 = pairOf ("first" , 2 );
16
+ var pair2 = pairOf ("first" , 2 );
17
+
18
+ assert (pair1 == pair2);
19
+ });
13
20
});
14
21
}
You can’t perform that action at this time.
0 commit comments