Skip to content

Commit

Permalink
refactor(quality): ♻️ rewrite compareTo without relying on `runtime…
Browse files Browse the repository at this point in the history
…Type` (#594)

Signed-off-by: Albert Mañosa <26429103+albertms10@users.noreply.github.com>
  • Loading branch information
albertms10 authored Feb 22, 2025
1 parent dc9119e commit 2c5d5b9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/src/interval/quality.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,15 @@ sealed class Quality implements Comparable<Quality> {
@override
int compareTo(Quality other) => compareMultiple([
() => semitones.compareTo(other.semitones),
// TODO(albertms10): rewrite without relying on `runtimeType`.
// ignore: no_runtimetype_tostring
() => '$runtimeType'.compareTo('${other.runtimeType}'),
() {
if (this is PerfectQuality && other is ImperfectQuality) {
return 1;
}
if (this is ImperfectQuality && other is PerfectQuality) {
return -1;
}
return 0;
},
]);
}

Expand Down

0 comments on commit 2c5d5b9

Please sign in to comment.