nil is not the same as void. You can set the variable to nil, but you cannot set it to void. If a function returns nil, it can be assigned to a variable without error, but try it with the void function (in java or in some such language that supports void functions), and the compiler will bark. I am not an expert on ruby, but I can not find any signs that the void concept is supported. All functions return something, even if it is zero. If this is not the case, I hope someone with more knowledge of the ruby ββcan provide a counterexample.
A variable, especially in ruby ββwhere everything is an object, is a thing with a name and a place to store an address that points to an object somewhere on the heap. Setting a variable to nil means setting its pointer to a single instance of NilClass. (true and false are similar, there is one instance of TrueClass and FalseClass.)
I understand that C has a thing called void pointers. This is a completely different use of the word void. The void pointer actually contains the address and points to something. Let them ignore them this time; I only mention them in order to avoid fruitless retorts. We focus on ruby ββfeatures that literally don't return anything that doesn't exist, as far as I can tell.
Carlos Konstanski
source share