Deutsch

C# - pattern matching - many discards

10.03.24 18:56
Re: C# - pattern matching - many discards
 
в ответ 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);
    } 
 

Перейти на