Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Idiomatic way to avoid variable shadowing in Nim

Suppose that I want to define a variable called sum, but the name collides with some predefined function. In Python, I would write something like _sum or sum_ to refer to the local variable. However, using underscore in Nim leads to an invalid token error. Is there an accepted naming convention to deal with such cases?

like image 931
hilberts_drinking_problem Avatar asked Nov 24 '25 08:11

hilberts_drinking_problem


1 Answers

Change both to more descriptive names like sumProducts, sumHorses.

like image 72
def- Avatar answered Nov 28 '25 14:11

def-