Bird
0
0

What is the main purpose of a predicate method in Ruby?

easy📝 Conceptual Q1 of 15
Ruby - Methods
What is the main purpose of a predicate method in Ruby?
ATo modify global variables
BTo return a boolean value indicating a condition
CTo print output to the console
DTo perform arithmetic calculations
Step-by-Step Solution
Solution:
  1. Step 1: Understand predicate method naming

    Predicate methods in Ruby always end with a question mark and are designed to answer yes/no questions.
  2. Step 2: Identify the return type

    They return true or false, which are boolean values indicating if a condition is met.
  3. Final Answer:

    To return a boolean value indicating a condition -> Option B
  4. Quick Check:

    Predicate method purpose = boolean return [OK]
Quick Trick: Predicate methods always return true or false [OK]
Common Mistakes:
  • Thinking predicate methods perform actions
  • Assuming they return strings
  • Confusing with methods that print output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes