Created
August 12, 2014 07:12
-
-
Save gerrywastaken/85d5d13408d0dc4ed7db to your computer and use it in GitHub Desktop.
Inconsistent reporting when accessing something that doesn't exist
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
irb(main):017:0> val = RBENV_VERSI0N | |
NameError: uninitialized constant RBENV_VERSI0N | |
from (irb):17 | |
from /Users/gerardcaulfield/.rbenv/versions/2.1.2/bin/irb:11:in `<main>' # Fair enough | |
irb(main):018:0> val = rbenv_versi0n | |
NameError: undefined local variable or method `rbenv_versi0n' for main:Object | |
from (irb):18 | |
from /Users/gerardcaulfield/.rbenv/versions/2.1.2/bin/irb:11:in `<main>' # Oh right | |
irb(main):019:0> val = Class.rbenv_versi0n | |
NoMethodError: undefined method `rbenv_versi0n' for Class:Class | |
from (irb):19 | |
from /Users/gerardcaulfield/.rbenv/versions/2.1.2/bin/irb:11:in `<main>' # My bad | |
irb(main):020:0> val = ENV['RBENV_VERSI0N'] | |
=> nil # Oh!? Wha??? | |
irb(main):039:0> val = ENV['RBENV_VERSION'] ? ENV['RBENV_VERSI0N'] : raise('the key does not exist') | |
=> nil # Splitting the check from the access does not prevent this issue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment