▲ | Mystery-Machine 7 days ago | |||||||
PHP:
Ruby:
I understand this is not pipe operator, but just look at that character difference across these two languages.// <- wtf This comment was my $0.02. | ||||||||
▲ | Alifatisk 7 days ago | parent | next [-] | |||||||
Can't the pipe operator be easily mimicked in Ruby thanks to its flexibility? I'm thinking of something like this:
which then can be in the following way:
Or if we just created an alias for then #then method:
then it can be used like in this way:
| ||||||||
| ||||||||
▲ | moebrowne 7 days ago | parent | prev | next [-] | |||||||
The trailing semi-colon on a new line helps prevent Git conflicts and gives cleaner diffs. It's the same reason PHP allows trailing commas in all lists. | ||||||||
▲ | daneel_w 7 days ago | parent | prev | next [-] | |||||||
Putting the delimiter on a line of its own is a syntactical trick that helps bringing small additions down to a neater 1-line diff instead of a 2-line diff. You've probably run into it many times before in other contexts without thinking of it. Arrays/hashes, quoted multi-line strings etc. | ||||||||
▲ | hu3 6 days ago | parent | prev [-] | |||||||
People use Laravel Collections or similar Symfony array wrapper to achieve chaining. Most PHP code I see look like your Ruby example. |