A method name can end with a question mark ?
def has_completed?
return count > 10
end
but a variable name cannot.
Now this is just a thought, but I think methods with names like empty?
suggest that a some sort of check has to be made inside and object or a class (depending on the context). This check or evaluation means an action must be done. Overall, since we are asking (thus, ?
) object for some state, means there is a possibility that object's state could change throughout the application's lifecycle. A variable could be outdated, but ?
-method (check) will be done in the specific moment, thus providing an up-to-date information on some state that could be presented in a boolean form.
So I'd like to think that this is a design constraint provided by the architect (Matz) to enforce a more logical, close-to-real-life coding approach.
You'd have to ask Matz to get an authoritative answer. However,
finished?
would imply a specific type (boolean) which appears somewhat contradictory to me.