Advanced Ruby
Q94 / 100

How does Ruby's "===" (case equality) operator differ across different classes such as Range, Regexp, Class, and Proc when used in "case/when"?

Correct! Well done.

Incorrect.

The correct answer is B) Each class defines "===" with custom semantics — Range checks inclusion, Regexp checks a pattern match, Class checks instance membership, and Proc calls itself with the value — making case/when extremely flexible

B

Correct Answer

Each class defines "===" with custom semantics — Range checks inclusion, Regexp checks a pattern match, Class checks instance membership, and Proc calls itself with the value — making case/when extremely flexible

Explanation

The flexibility of case/when comes from each class providing its own meaningful "===" implementation, allowing a single case statement to match values against ranges, types, patterns, or even custom callable conditions.

Progress
94/100