X
- The type to iterate overpublic final class ForEach<X> extends Object implements Proc<Iterable<? extends X>>
Proc
for each element of an
Iterable
This class can be effectively used to iterate through a collection, just like
Stream.forEach(java.util.function.Consumer)
works:
new ForEach(
new ProcOf<>(input -> System.out.printf("\'%s\' ", input)),
).execute(
new IterableOf<>("Mary", "John", "William", "Napkin")
); // will print 'Mary' 'John' 'William' 'Napkin' to standard output
There is no thread-safety guarantee.
Copyright © 2017–2022 Cactoos. All rights reserved.