Advanced Ruby
Q91 / 100

What is the significance of "frozen_string_literal: true" magic comment at the top of a Ruby file?

Correct! Well done.

Incorrect.

The correct answer is B) It causes all string literals in the file to be frozen by default, which can reduce object allocations and prevent accidental mutation, but requires explicit .dup if mutation is needed

B

Correct Answer

It causes all string literals in the file to be frozen by default, which can reduce object allocations and prevent accidental mutation, but requires explicit .dup if mutation is needed

Explanation

With this magic comment, every string literal becomes frozen automatically, improving performance by avoiding repeated allocation of identical immutable strings, though code that mutates string literals in place will need adjustment.

Progress
91/100