Skip to content

Instantly share code, notes, and snippets.

@aprescott
Created March 27, 2014 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aprescott/9817051 to your computer and use it in GitHub Desktop.
Save aprescott/9817051 to your computer and use it in GitHub Desktop.
class Symbol
def |(other)
self.to_proc | other
end
end
class Proc
def |(other)
proc { |arg| other.to_proc.call(self.call(arg)) }
end
end
class X
def initialize(value)
@value = value
end
def foo
Y.new(@value)
end
end
class Y
def initialize(x)
@x = x
end
def bar
-10 * @x
end
end
x1, x2 = X.new(1), X.new(-2)
[x1, x2].map(&:foo | :bar)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment