As far as I'm concerned, you cannot use operators as in '+=' and the likes on nil values.
By this means, if you want to use such an operator on a variable, it has to be defined. This code works:
var = 0
var += 5
print var # prints 5
This code does NOT work:
If you used such an operator before a definition, it would result in such an error.
About the NilClass. By default, all variables have to be defined somehow. This is done by using '=' and a value.
Once this has been done, all operators and methods available for that type or class will become available. A simple method to check if it's a certain type:
if var.is_a?(Integer)
var += 1
else
var = 0 #defines as an integer
end
I haven't tried, but I reckon that using Integer.new is also a possible way to define integers, such as Array.new works for arrays.
I know you said you did not have an example, but how did you encounter the error without some code?
Can't you provide that code if your question still remains?
Hope this is of any use.