Can't the pipe operator be easily mimicked in Ruby thanks to its flexibility?
I'm thinking of something like this:
class Object
def |>(fn)
fn.call(self)
end
end
which then can be in the following way: result = arr
|> ->(a) { a.uniq }
|> ->(a) { a.flatten }
|> ->(a) { a.map(&:tags) }
Or if we just created an alias for then #then method: class Object
alias_method :|>, :then
end
then it can be used like in this way: arr
|> :uniq.to_proc
|> :flatten.to_proc
|> ->(a) { a.map(&:tags) }