Home>
p [0,1] .min == 0
# =>
0


I want to output 1 with the ternary operator.
I don't know how to access the array.

  • Answer # 1

    l = [0,1]
    l.min == 0? l.reject {| i | i == 0} .min: l.min

    I don't think there is any real advantage of ternary operators, but as an exercise.

  • Answer # 2

    The range of values ​​in [] is ambiguous, but is a non-negative integer. Or is it a non-negative real number?
    And
    You can do this with ternary operations and use min. difficult. . .
    ([3,1,0,8,9]-[0]). Min

    Through ternary operations,

  • Answer # 3

    ([0,1]-[0]). min