Bird
0
0

Which of the following is the correct syntax to freeze an array named items in Ruby?

easy📝 Syntax Q3 of 15
Ruby - Functional Patterns in Ruby
Which of the following is the correct syntax to freeze an array named items in Ruby?
Aitems.freeze()
Bfreeze(items)
Citems.freeze = true
Ditems.frozen = true
Step-by-Step Solution
Solution:
  1. Step 1: Recall freeze method syntax

    The freeze method is called on the object as object.freeze() without arguments.
  2. Step 2: Analyze other options

    freeze(items) is invalid syntax, and freeze is not an attribute to assign.
  3. Final Answer:

    items.freeze() -> Option A
  4. Quick Check:

    freeze is a method called on object = C [OK]
Quick Trick: Call freeze as a method on the object: object.freeze() [OK]
Common Mistakes:
  • Using freeze as a function
  • Assigning freeze as a property
  • Omitting parentheses causing confusion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Ruby Quizzes