I think the article is wrong. His rewrite on line 06. should use if instead of unless.
$ irb
>> b
NameError: undefined local variable or method `b' for main:Object
from (irb):1
>> if defined? b
>> b = 5
>> end
=> nil
>> b
=> nil
>> defined? b
=> "local-variable"