(误
class Object
class Proxy < BasicObject
def method_missing name, *args, &block
@target = @target.send(name, *args, &block)
end
def initialize target
@target = target
end
end
def pipe &block
Proxy.new(self).instance_eval &block
end
end
p [1,2,3].map{|x| %w{a b c d}[x] }.join.capitalize # => "Bcd"
[1,2,3].pipe do
map{|x| %w{a b c d}[x] }
join
capitalize
p self
end # => "Bcd"