I am new to Ruby and a bit confused about how the ternary operator, ?:
, works.
According to the book Engineering Software as a Service: An Agile Approach Using Cloud Computing:
every operation is a method call on some object and returns a value.
In this sense, if the ternary operator represents an operation, it is a method call on an object with two arguments. However, I can't find any method of which the ternary operator represents in Ruby's documentation. Does a ternary operator represent an operation in Ruby? Is the above claim made by the book mentioned wrong? Is the ternary operator in Ruby really just a syntactic sugar for if ... then ... else ... end
statements?
Please note: My question is related to How do I use the conditional operator (? :) in Ruby? but not the same as that one. I know how to use the ternary operator in the way described in that post. My question is about where ternary operator is defined in Ruby and if the ternary operator is defined as a method or methods.
ternary operator
in the way described in that post. My question is about whereternary operator
is defined in Ruby and if theternary operator
is defined as a method or methods. – Isaac Tonil
being a great example. – Marc Baumbach