mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Shorten compare_values case statements
This commit is contained in:
parent
556d4783bf
commit
526a998e41
1 changed files with 6 additions and 15 deletions
|
@ -45,23 +45,14 @@ module Spectator
|
|||
when Range
|
||||
# Ranges can only be matched against if their right side is comparable.
|
||||
# Ensure the right side is comparable, otherwise compare directly.
|
||||
if b.is_a?(Comparable(typeof(b)))
|
||||
a === b
|
||||
else
|
||||
a == b
|
||||
end
|
||||
return a === b if b.is_a?(Comparable(typeof(b)))
|
||||
a == b
|
||||
when Tuple, Array
|
||||
if b.is_a?(Tuple) || b.is_a?(Array)
|
||||
compare_tuples(a, b)
|
||||
else
|
||||
a === b
|
||||
end
|
||||
return compare_tuples(a, b) if b.is_a?(Tuple) || b.is_a?(Array)
|
||||
a === b
|
||||
when NamedTuple, Hash
|
||||
if b.is_a?(NamedTuple) || b.is_a?(Hash)
|
||||
compare_named_tuples(a, b)
|
||||
else
|
||||
a === b
|
||||
end
|
||||
return compare_named_tuples(a, b) if b.is_a?(NamedTuple) || b.is_a?(Hash)
|
||||
a === b
|
||||
else
|
||||
a === b
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue