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.
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.
Uninitialized global variables and instance variables have default values of nil.
You can take a look at the documentation:
http://www.rubyist.net/~slage...
http://www.rubyist.net/~slage...
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.