Skip to content

Code Highlight markup and Link colouration fix scope.adoc #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Language/Variables/Variable Scope & Qualifiers/scope.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ subCategories: [ "Variable Scope & Qualifiers" ]
=== Description
Variables in the C++ programming language, which Arduino uses, have a property called scope. This is in contrast to early versions of languages such as BASIC where every variable is a _global_ variable.

A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. setup(), loop(), etc. ), is a _global_ variable.
A global variable is one that can be seen by every function in a program. Local variables are only visible to the function in which they are declared. In the Arduino environment, any variable declared outside of a function (e.g. `link:../../../structure/sketch/setup[setup()]`, `link:../../../structure/sketch/loop[loop()]`, etc. ), is a _global_ variable.

When programs start to get larger and more complex, local variables are a useful way to insure that only one function has access to its own variables. This prevents programming errors when one function inadvertently modifies variables used by another function.

It is also sometimes handy to declare and initialize a variable inside a `for` loop. This creates a variable that can only be accessed from inside the for-loop brackets.
It is also sometimes handy to declare and initialize a variable inside a `link:../../../structure/control-structure/for[for]` loop. This creates a variable that can only be accessed from inside the link:../../../structure/control-structure/for[`for`]-loop brackets.
[%hardbreaks]

--
Expand Down