A method name can end with a question mark ?
def has_completed?
return count > 10
end
but a variable name cannot.
What is the reason for that? Isn't it convenient to have variable names ending the same way too? Given that we usually can't tell whether foobar
is a method or a variable just by looking at the name foobar
anyway, why the exception for the ?
case?
And how should I work with this? Maybe always to use has
or is
in the code?
if process_has_completed
...
end
if user_is_using_console
...
end
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…