testcounting.rb:8:in `counting': undefined method `+' for nil:NilClass (NoMethodError)

from counting.rb:12:in `<main>'

I am not sure why it doesn't recognize it but I'm coming from C++ so I am completely new at this.

Here is my code:

def counting() print "test" x += 1 puts x end counting() counting() counting() counting() counting()

thx