3 ms·
This article makes a great case WHY the pipe operator is useful, but why didn't they just rewrite those functions to support method chaining? ` $profit = [1, 4,
by chuck8088 1y ago
This article makes a great case WHY the pipe operator is useful, but why didn't they just rewrite those functions to support method chaining?
`
$profit = [1, 4, 5]
.loadSeveral()
.filter(isOnSale())
.map(sellWidget())
.array_sum();
`
this has the side benefit of 'looking normal'
- wsatb 1y agoBackwards compatibility. The language has done a pretty amazing job at adding features over the last 10 years without really breaking a lot of old code. I believe PHP still runs about 75% of the internet, so that's pretty huge.
- moebrowne 1y agoThe Python 2 to 3 upgrade is a example of how important backwards compatibility is
- troupo 1y agoBecause pipes work on all functions, not just object methods. So your business logic, validations etc. don't have to be methods of the built-in objects. And there's nothing abnormal about pipes