Skip to content

Difference between tap / delete and except in Ruby Hash #2

Answered by fortune-web
titan2gman asked this question in Q&A
Discussion options

You must be logged in to vote

Object#tap. Object#tap:

Yields self to the block, and then returns self. The primary purpose of this method is to “tap into” a method chain, in order to perform operations on intermediate results within the chain.

This does not create a "copy" so by using Hash#delete you are modifying source in place.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by titan2gman
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants