Created
January 22, 2009 05:02
-
-
Save joho/50426 to your computer and use it in GitHub Desktop.
A small problem with my lazy loader
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
# http://github.com/joho/lazy-loader | |
# discovered a small problem when I lazy load something that returns nil | |
# lazy_load in this case is proxying nil | |
# so ideally a would behave the same as a = nil | |
a = lazy_load { nil } | |
# this is fine | |
nil.nil? # => true | |
a.nil? # => true | |
# this is broken but..... | |
# i can fix it by opening up NilClass | |
a == nil # => true | |
nil == a # => false | |
# but what do i do about these? | |
!!nil # => false | |
!!a # => true | |
if a | |
puts "blah!" | |
end # => "blah!" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment