In addition to other replies, this convention is not just for boolean values. It is for truthy or falsy values.
For example defined? method returns nil if expression is not defined or a string about expression if it is defined. The reason there is a ? at the end of this method is that you can use it in your if statements etc. to check an expression is defined or not.
defined? Object
=> "constant"
defined? undefined_variable
=> nil
Simply because you are asking an Object to respond to that method with an assertion true | false.
Is a smart notation to distinguish this kind of methods from others that return non boolean Objects
Siddarthan Sarumathi Pandian
Full Stack Dev at Agentdesks | Ex Hashnode | Ex Shippable | Ex Altair Engineering
It's purely syntactic sugar.
Just to make it easy for us to read code.
if number.zero?can be read as "if the number is zero".