Bird
0
0

Why do Ruby predicate methods conventionally end with a question mark?

hard📝 Conceptual Q10 of 15
Ruby - Methods
Why do Ruby predicate methods conventionally end with a question mark?
ATo improve performance
BTo make the method private
CTo allow method overloading
DTo indicate the method returns a boolean value
Step-by-Step Solution
Solution:
  1. Step 1: Understand Ruby naming conventions

    Methods ending with '?' signal they answer yes/no questions by returning true or false.
  2. Step 2: Eliminate incorrect options

    Ending with '?' does not affect privacy, overloading, or performance.
  3. Final Answer:

    To indicate the method returns a boolean value -> Option D
  4. Quick Check:

    Question mark means boolean return [OK]
Quick Trick: Question mark signals boolean return in method names [OK]
Common Mistakes:
  • Thinking '?' changes method visibility
  • Assuming '?' enables overloading
  • Believing '?' affects speed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes