大家讲道理2017-04-25 09:05:55
Uninitialized global variables and instance variables have default values of nil.
You can take a look at the documentation:
http://www.rubyist.net/~slage...
Before initialization, a global variable has the special value nil.
http://www.rubyist.net/~slage...
instance variables have the nil value until they are initialized.
给我你的怀抱2017-04-25 09:05:55
Accessing an uninitialized variable returns nil, and nil can be regarded as an error.
Why? Because it is convenient, it is so troublesome to report errors every time and deal with them. Also, you are an awesome programmer, capable of using programming languages well, and will not screw up the program because of nil (๑•̀ㅂ•́)و✧, so I won’t report an error.