flat Tap
Performs a flatMap across the supplied function, propagating failures or absence but preserving the original present value.
1.present().flatTap { a -> "bad".failure() } // Failure("bad")
1.present().flatTap { a -> Absent } // Absent
1.present().flatTap { a -> a + 2 } // Present(1) -- value preserved
Content copied to clipboard