In a Ruby beginner's article&&
Or||
I sometimes see what is written as "conditional operator".
Probably because they are used in conditional expressions, I think they are called so, but these are "logical operators".
On the other hand, the conditional operator is
(1..9).each do |n|
puts "#{ n } is #{ n.odd? ? "odd" : "even" }"
end
The formula that appears in
n.odd? ? "odd" : "even"
It is an operator represented by the two symbols ?:
.
It is also called a "ternary operator" because it takes three terms (in Ruby, there is no operator that takes three terms other than the conditional operator).
Operator Expression (Ruby 3.0.0 Reference Manual)