Вход на сайт
C# - pattern matching - many discards
4911 просмотров
Перейти к просмотру всей ветки
Срыв покровов патриот
в ответ alex445 10.03.24 18:49
да вроде то же самое есть
private static Function<Integer, Integer> multiply = x -> x * 2;
private static Function<Integer, Integer> add = x -> x + 2;
private static Function<Integer, Unit> logOutput = x -> {
logger.info("Data:" + x);
return Unit.unit();
};
public static Unit execute(Integer input) {
Function<Integer, Unit> pipeline = multiply
.andThen(add)
.andThen(logOutput);
return pipeline.apply(input);
}