Q. What does the 'attr_accessor' method do in Ruby?

  • (A) Defines getter methods only
  • (B) Defines setter methods only
  • (C) Defines both getter and setter methods
  • (D) Defines class methods
πŸ’¬ Discuss
βœ… Correct Answer: (C) Defines both getter and setter methods
Explanation: 'attr_accessor' creates both getter and setter methods for instance variables.
Explanation by: Rati Dubey
'attr_accessor' creates both getter and setter methods for instance variables.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
91
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Rati Dubey
Publisher
πŸ“ˆ
86%
Success Rate