Intermediate
Ruby
Q62 / 100
What does "Object.new.tap { |o| puts o }" demonstrate about the "tap" method?
Correct! Well done.
Incorrect.
The correct answer is B) tap yields the object to the block (for side effects like logging/debugging) and then returns the original object unchanged
B
Correct Answer
tap yields the object to the block (for side effects like logging/debugging) and then returns the original object unchanged
Explanation
tap passes self to the given block and returns self, useful for inserting debugging or side-effect code into a method chain without breaking it.
Progress
62/100