1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] No need to use max_by when array.size == 1

https://github.com/ruby/reline/commit/7e56c8af05
This commit is contained in:
aycabta 2021-09-06 04:11:24 +09:00 committed by git
parent 8913b9b742
commit d07060c42a

View file

@ -70,8 +70,8 @@ class Reline::KeyStroke
key_mapping.keys.select { |lhs|
lhs.start_with? input
}.tap { |it|
return :matched if it.size == 1 && (it.max_by(&:size)&.== input)
return :matching if it.size == 1 && (it.max_by(&:size)&.!= input)
return :matched if it.size == 1 && (it[0] == input)
return :matching if it.size == 1 && (it[0] != input)
return :matched if it.max_by(&:size)&.size&.< input.size
return :matching if it.size > 1
}