Skip to content

Instantly share code, notes, and snippets.

@kiote
Created March 24, 2016 16:21
Show Gist options
  • Save kiote/c370a15a99f693c30c7f to your computer and use it in GitHub Desktop.
Save kiote/c370a15a99f693c30c7f to your computer and use it in GitHub Desktop.
irb(main):001:0> def a(b = {})
irb(main):002:1> puts b[:one]
irb(main):003:1> end
=> :a
irb(main):004:0> a
=> nil
irb(main):005:0> a(nil)
NoMethodError: undefined method `[]' for nil:NilClass
from (irb):2:in `a'
from (irb):5
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:110:in `start'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/console.rb:9:in `start'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:68:in `console'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /app/vendor/bundle/ruby/2.2.0/gems/railties-4.2.5.2/lib/rails/commands.rb:17:in `<top (required)>'
from /app/bin/rails:26:in `require'
from /app/bin/rails:26:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment