GDQuest / learn-gdscript

Learn Godot's GDScript programming language from zero, right in your browser, for free.
https://gdquest.github.io/learn-gdscript/
Other
2.11k stars 160 forks source link

Lesson 8 : variable name must be unique in a "function or block of code" #75

Closed survivant closed 2 years ago

survivant commented 2 years ago

in : https://gdquest.github.io/learn-gdscript/#course/lesson-8-defining-variables/lesson.tres image

the variables names should be unique, but in a function or block of code. Let say that we should tell the beginner that it must be unique within a file.

OK, I didn't try in Godot, I'm not sure if it's the case like other programming language

example

var index=0

func method1():
    var index=5
    ....

function method2():
   var index=1
... 
NathanLovato commented 2 years ago

It's true that should be nuanced. The idea is that you shouldn't shadow properties in your code. I'll rephrase that, thanks