This question already has an answer here:

In Java, something like i++ would increment i by 1.

How can I do in Ruby? Surely there has to be a better way than i = i + 1?

marked as duplicate by the Tin Man, Neil Slater, iCodez, Johan, Cole Johnson Oct 1 '13 at 2:49

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 102 down vote accepted

From the documentation,

Ruby has no pre/post increment/decrement operator. For instance, x++ or x-- will fail to parse

So, you can do

i += 1

which is equivalent of i = i + 1

Not the answer you're looking for? Browse other questions tagged or ask your own question.