marcmorente's avatar

Marc Morente

marcmorente

Member since

20

Total Reputation

1

Total Arguments

2

Total Votes for Arguments

Arguments and votes

1

I think it's a very nice way to simplify code. For me it looks readable and cleaner without the need of creating temporal variables.

Share:
Read the RFC: The Pipe Operator marcmorente avatar
marcmorente
voted yes
23

For example:

$result = "Hello World"
    |> 'htmlentities'
    |> 'str_split'
    |> fn($x) => array_map('strtoupper', $x)
    |> fn($x) => array_filter($x, fn($v) => $v != 'O');

Is 'nicer' since it has better readability and clearer syntax than:

$result = array_filter(
        str_split(
            strtoupper(
                htmlentities("Hello World")
            )
        ),
        fn($v) => $v != '0'
    );
Share:
Read the RFC: The Pipe Operator josebenraul avatar
josebenraul
voted yes
RSS Feed Contribute Watch on YouTube Our License
© 2024 RFC Vote. This project is open source. Contribute and collaborate with us!