Skip to content

Instantly share code, notes, and snippets.

@joho
Created January 22, 2009 05:02
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 joho/50426 to your computer and use it in GitHub Desktop.
Save joho/50426 to your computer and use it in GitHub Desktop.
A small problem with my lazy loader
# 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