[0, 1, 2, 3, 4, 5].max
# => 5
[0, 1, 2, 3, 4, 5].max(2)
# => [5, 4]
[0, 1, 2, 3, 4, 5].to_h { |number| [number, number.to_s.ord] }
# => {0 => 48, 1 => 49, 2 => 50, 3 => 51, 4 => 52, 5 => 53}
[0, 1, 2, 3, 4, 5].max { it.to_s.ord }
# => 5
[0, 1, 2, 3, 4, 5].max(2) { it.to_s.ord }
# => [0, 4]
Why [0, 4]
?
[0, 1, 2, 3, 4, 5].min
# => 0
[0, 1, 2, 3, 4, 5].min(2)
# => [0, 1]
[0, 1, 2, 3, 4, 5].to_h { |number| [number, number.to_s.ord] }
# => {0 => 48, 1 => 49, 2 => 50, 3 => 51, 4 => 52, 5 => 53}
[0, 1, 2, 3, 4, 5].min { it.to_s.ord }
# => 0
[0, 1, 2, 3, 4, 5].min(2) { it.to_s.ord }
# => [3, 2]
Why [3, 2]
?
(0...0).one?
# => false
[].one?
# => false
(0...0).first
# => 0
[].first
# => nil
(0...0).to_a
# => []