Skip to content

Instantly share code, notes, and snippets.

@JoshCheek
Created August 16, 2016 22:54
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 JoshCheek/ffb8b3612710d6e0e7976b94c08ed631 to your computer and use it in GitHub Desktop.
Save JoshCheek/ffb8b3612710d6e0e7976b94c08ed631 to your computer and use it in GitHub Desktop.
Syntactic Nilmare
# be sure to use 2.3.0, b/c it uses the new "safe navigation" operator
RUBY_VERSION # => "2.3.0"
def show(arg)
arg # => true, {:nil=>:nil?}, {:nil=>false}
end # => :show
nil # => nil
nil.nil? # => true
nil&.nil # => nil
nil&nil # => false
nil?.nil? # => false
nil?&nil? # => false
nil?&%?nil? # => false
nil&:nil # => false
nil&:nil? # => false
nil&.&nil? # => nil
nil&.&nil # => nil
nil&.|nil # => nil
nil&.& &:nil? # => nil
nil&&nil # => nil
nil&&nil? # => nil
nil&&:nil # => nil
nil&&:nil? # => nil
show nil::nil? # => true
show nil: :nil? # => {:nil=>:nil?}
show nil:nil? # => {:nil=>false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment