liveBook · Manning

Tap combinator

A tap combinator applies an operation to a value for its side effects and returns the original value unchanged.

How 2 Manning books explain it

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

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.