Ruby - Functional Patterns in Ruby
What will be the output of this Ruby code using the pipeline operator?
def triple(x)
x * 3
end
def decrement(x)
x - 1
end
result = 2 |> triple |> decrement |> triple
puts resultWhat will be the output of this Ruby code using the pipeline operator?
def triple(x)
x * 3
end
def decrement(x)
x - 1
end
result = 2 |> triple |> decrement |> triple
puts result2 |> tripletriple(2) returns 2 * 3 = 6.6 |> decrementdecrement(6) returns 6 - 1 = 5.5 |> tripletriple(5) returns 5 * 3 = 15.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions