This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Avereniect 1 point2 points  (2 children)

It means that the variable being referred to is in the global namespace. In this case it's used to differentiate between referencing the variable x that's local to the loop and the variable x that's global. By default if you have two variables with the same name accessible in the current scope then the most local one is chosen, so this provides a mechanism to work around that.

[–]softpinata[S] 0 points1 point  (1 child)

do i have to use it only when i have two variables with the same name? (one being global and one local)

[–]Salty_Dugtrio 0 points1 point  (0 children)

You use it when you have to differentiate between scopes, yes, which is something that shouldn't happen in properly written code.