yegor256 / cactoos

Object-Oriented Java primitives, as an alternative to Google Guava and Apache Commons
https://www.cactoos.org
MIT License
735 stars 164 forks source link

Example of iteration #1670

Open advasileva opened 1 year ago

advasileva commented 1 year ago

In README.md there is an example in the Iterables/Collections/Lists/Sets section:

new And(
  new Mapped<>(
    new FuncOf<>(
      input -> {
        System.out.printf("Item: %s\n", input);
      }
    ),
    new IterableOf<>("how", "are", "you", "?")
  )
).value();

It does not compile with an explanation:

Missing return statement
Candidates for new FuncOf() are:  
  FuncOf(Proc<? super X> proc, Y result)
  FuncOf(Scalar<? extends Y> scalar)
  FuncOf(Func<? super X, ? extends Y> fnc)
advasileva commented 1 year ago

It worked for me like this:

new And(
  new Mapped<>(
    new FuncOf<>(
      input -> {
        System.out.printf("Item: %s\n", input);
      },
      new True()
    ),
    new IterableOf<>("how", "are", "you", "?")
  )
).value();
victornoel commented 1 year ago

@advasileva thank you, let's then update the README and ensure all examples work.

victornoel commented 1 year ago

@0crat in

victornoel commented 1 year ago

@0crat assign @advasileva