Ruby - Functional Patterns in RubyWhy does freezing an object in Ruby not guarantee deep immutability of nested objects?ABecause freeze converts nested objects to stringsBBecause freeze only prevents modifications to the object itself, not its nested objectsCBecause freeze only works on arrays and hashesDBecause freeze automatically duplicates nested objectsCheck Answer
Step-by-Step SolutionSolution:Step 1: Understand shallow freezefreeze makes the object immutable but does not affect nested objects inside it.Step 2: Nested objects remain mutableNested arrays or hashes inside a frozen object can still be changed unless they are frozen separately.Final Answer:Because freeze only prevents modifications to the object itself, not its nested objects -> Option BQuick Check:freeze is shallow, nested objects stay mutable unless frozen [OK]Quick Trick: freeze is shallow; freeze nested objects separately for deep immutability [OK]Common Mistakes:Thinking freeze converts nested objectsAssuming freeze duplicates nested objectsBelieving freeze works only on arrays/hashes
Master "Functional Patterns in Ruby" in Ruby9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More Ruby Quizzes Advanced Metaprogramming - Class_eval and instance_eval - Quiz 6medium Concurrent Programming - Fiber for cooperative concurrency - Quiz 13medium Concurrent Programming - GIL (Global Interpreter Lock) impact - Quiz 11easy Functional Patterns in Ruby - Pure functions concept - Quiz 9hard Gems and Bundler - Bundler for dependency resolution - Quiz 1easy Gems and Bundler - RubyGems repository - Quiz 6medium Regular Expressions - Why regex is powerful in Ruby - Quiz 11easy Testing with RSpec and Minitest - Test-driven development workflow - Quiz 12easy Testing with RSpec and Minitest - Test-driven development workflow - Quiz 9hard Testing with RSpec and Minitest - Let and before hooks - Quiz 1easy