Question
What is the purpose of the question mark operator in Ruby?
Sometimes it appears like this:
assert !product.valid?
sometimes it's in an if
construct.
Answer
It is a code style convention; it indicates that a method returns a boolean value (true or false) or an object to indicate a true value (or “truthy” value).
The question mark is a valid character at the end of a method name.
<https://docs.ruby-lang.org/en/2.0.0/syntax/methods_rdoc.html#label- Method+Names>