M
Michal
Hello,
today (when explaining bits of Ruby to my friend)
I got confused by this:
$ cat a.rb
b = 4
if b == 1
a = 1
end
p a
$ ./a.rb
nil
$ ruby --version
ruby 1.8.2 (2004-07-29) [i686-linux]
(latest gentoo ebuild)
Why is it that 'a' is nil and not undefined? (i would expect:
undefined local variable or method `a' for main:Object (NameError)
)
Thanks in advance,
M.
today (when explaining bits of Ruby to my friend)
I got confused by this:
$ cat a.rb
b = 4
if b == 1
a = 1
end
p a
$ ./a.rb
nil
$ ruby --version
ruby 1.8.2 (2004-07-29) [i686-linux]
(latest gentoo ebuild)
Why is it that 'a' is nil and not undefined? (i would expect:
undefined local variable or method `a' for main:Object (NameError)
)
Thanks in advance,
M.