3 ms·
> Are we talking about Ruby? I wasn't thinking specifically of Ruby (and indeed I don't know Ruby, nor was I aware that it has this kind of support). Rather,
by funklute 5y ago
> Are we talking about Ruby?
I wasn't thinking specifically of Ruby (and indeed I don't know Ruby, nor was I aware that it has this kind of support).
Rather, I was thinking about programming languages in general, since the top-level comment seemed to be talking about the general principle.
Out of 5 languages I use on a regular basis, only one of them has _some_ support for function composition. But even then, not as flexible as what you're demonstrating here. So my point is that across programming languages, the chaining approach is generally more readable than the composition approach. And that in turn favours methods over global functions.
If I ever start using Ruby, I would probably be on the fence about which approach is better though.