public static <E> Iterator<E> tap(Iterable<E> iterable, Consumer<E> consumer) {
        dbc.precondition(iterable != null, "cannot tap on a null iterable");
        return new TransformingIterator<E, E>(iterable.iterator(), new Tapper<E>(consumer));
    }
public static < E > Iterator < E > tap ( Iterable < E > iterable , Consumer < E > consumer ) { dbc . precondition ( iterable != null , "cannot tap on a null iterable" ) ; return new TransformingIterator < E , E > ( iterable . iterator ( ) , new Tapper < E > ( consumer ) ) ; }
Creates an iterator yielding each element of the source iterable after
applying the passed consumer. This application is evaluated lazily when the
resulting iterator is consumed. E.g:
<code>
tap([1,2,3], sideEffect) -> [1, 2, 3]
</code>

@param <E> the element type parameter
@param iterable the iterable
@param consumer the consumer to be applied
@return an iterator that when consumed applies a side effect to every
element