Tap combinator
A tap combinator applies an operation to a value for its side effects and returns the original value unchanged.
The Well-Grounded Rubyist, Fourth Edition
tap yields its receiver to a supplied block and then returns that receiver unchanged as the method result.
- How it is used
- Uses tap to execute side-effecting or observational block code while preserving the receiver for subsequent operations.
- How deep it goes
- Explains yielding, unchanged return, chaining, and bang-method edge cases, but stops short of implementation internals.
- Examples
- Demonstrates printing an uppercased string, reversing after tap, and applying gsub! inside the block.
- What you can do after
- Apply it via Ruby method chains to inspect or modify receivers without replacing the chain's value.
Read how The Well-Grounded Rubyist, Fourth Edition explains tap combinator →
Functional Programming in JavaScript
A combinator that applies a function to a value for its side effects and then returns the original value unchanged.
- How it is used
- Bridges logging and other void functions into function composition while preserving the composed value.
- How deep it goes
- Defines tap’s behavior and signature, then demonstrates intermediate logging in composed JavaScript functions.
- Examples
- Uses debug logging to inspect cleaned input, length checks, and the final validation result.
- What you can do after
- Apply it via R.tap to add diagnostic actions to a composition without altering its returned value.
Read how Functional Programming in JavaScript explains tap combinator →
Related concepts
- blockuses · A code block is a grouped region of code treated as a unit, with boundaries and scope or execution behavior determined by its language or context.
- functionuses · A function is a callable program unit that performs an operation, may accept inputs, and can produce a result or side effect.
- combinatorkind of · A combinator is a function or computational construct that combines, composes, or transforms smaller functions or computations into a larger operation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

