Skip to content

Instantly share code, notes, and snippets.

@spickermann
Created February 25, 2014 01:31
Show Gist options
  • Save spickermann/9200851 to your computer and use it in GitHub Desktop.
Save spickermann/9200851 to your computer and use it in GitHub Desktop.
class Foo
def initialize(foo)
@foo = foo
end
def foo
@foo
end
def -@ # This is awesome
Foo(-foo)
end
end
def Foo(foo)
Foo.new(foo)
end
puts Foo(5).foo # => 5
puts Foo(-5).foo # => -5
puts -Foo(5).foo # => -5 (what is awesome)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment