Last active
February 27, 2020 22:31
-
-
Save davidcelis/2831543 to your computer and use it in GitHub Desktop.
NotClass
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Object | |
def not | |
NotClass.new(self) | |
end | |
end | |
class NotClass < BasicObject | |
instance_methods.grep(/^[^_]/).each { |m| undef_method m } | |
def initialize(object) | |
@object = object | |
end | |
def method_missing(name, *args, &block) | |
[email protected](name, *args, &block) | |
end | |
end | |
puts nil.not.nil? | |
puts 1.not.eql?(2) | |
puts [1, 3, 5, 7, 9].not.any? { |i| i % 2 == 0 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.