Advanced Ruby
Q90 / 100

What does "ObjectSpace::WeakMap" provide and why might it be used?

Correct! Well done.

Incorrect.

The correct answer is A) A hash-like structure that holds weak references to its keys/values, allowing the garbage collector to reclaim them if no other strong references exist, useful for caches that should not prevent garbage collection

A

Correct Answer

A hash-like structure that holds weak references to its keys/values, allowing the garbage collector to reclaim them if no other strong references exist, useful for caches that should not prevent garbage collection

Explanation

WeakMap holds references that do not count toward an object's reachability for garbage collection purposes, making it suitable for caches or object registries that shouldn't leak memory.

Progress
90/100