How to increase variables by 1 in Nim

Viewed 289

I would like to know how to increase variables in Nim by 1, alike the (variablename)++ function in other programming languages.

My Code by far:

int i = 1
int j = 1
for i in countup(1, 10):
  j = j + 1
  echo "number: "
  echo i

I want to change the j = j + 1 with the Nim version of: j++

2 Answers

You can use the += operator:

j += 1

You can increment a variable by one in Nim with the inc() function: inc(var_name)

Related