user14074696
user14074696

Reputation:

How to increase variables by 1 in Nim

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++

Upvotes: 3

Views: 867

Answers (2)

Jason
Jason

Reputation: 551

You can use the += operator:

j += 1

Upvotes: 5

Casper Majgaard
Casper Majgaard

Reputation: 101

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

Upvotes: 4

Related Questions