Created
January 10, 2011 15:40
-
-
Save antonrogov/772916 to your computer and use it in GitHub Desktop.
nil is true in ?:
This file contains 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 Proxy | |
instance_methods.each do |method| | |
undef_method(method) unless method =~ /(^__|^send$|^object_id$|^extend$)/ | |
end | |
def initialize(target) | |
@target = target | |
end | |
def method_missing(name, *args, &block) | |
@target.send(name, *args, &block) | |
end | |
end | |
n = Proxy.new(nil) | |
p nil ? 1 : 2 # 2 | |
p n ? 1 : 2 # 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment