Bird
0
0

Which of the following method names is correctly written to indicate it modifies the object in Ruby?

easy📝 Syntax Q12 of 15
Ruby - Methods
Which of the following method names is correctly written to indicate it modifies the object in Ruby?
Adelete
Bdelete!
Cdelete?
Ddeleted
Step-by-Step Solution
Solution:
  1. Step 1: Understand the meaning of ! suffix

    In Ruby, methods ending with ! usually modify the object or perform a 'dangerous' action.
  2. Step 2: Identify the method that modifies the object

    delete! clearly indicates modification, while delete may not, and delete? suggests a boolean check.
  3. Final Answer:

    delete! -> Option B
  4. Quick Check:

    Modification methods end with ! = delete! [OK]
Quick Trick: Use ! for methods that change the object [OK]
Common Mistakes:
  • Using ? instead of ! for modifying methods
  • Not adding ! for dangerous methods
  • Confusing method names without suffixes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes