I’m upgrading a rails 2 application to rails 3.2 and have come across what is described as an idiom.
person.tap |p| do
When I Googled for this and it appears to have been deprecated or moved. Is my understanding correct?
I ask because I can find a few examples of it on SO.
The
tapmethod has been in Ruby since 1.8.7:Note that 1.8.6 did not have
Object#tap. Presumably,tapwas in older versions of Rails (as a monkey patch onObject) but was added to Ruby itself in 1.8.7. Since 1.8.6 is rather ancient now, the Rails version was deprecated and, in more recent Rails releases, removed entirely.Object#tapis still around sotapitself has not been deprecated, just the Rails monkey patched version has been removed.