From the course: Processing: Interactive Data Visualization

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Understanding variable scope

Understanding variable scope - Processing Tutorial

From the course: Processing: Interactive Data Visualization

Start my 1-month free trial

Understanding variable scope

In the last movie, I gave you an overview of how to use variables within Processing. Again it's a great thing for saving time in coding for making use of information over and over again. And it's an essential practice for data visualization. In this movie, I want to give some more information about creating variables. The first thing I want to talk about is what's called the scope of a variable, and that is in Processing, a variable is either a local variable or it's a global variable. And I will demonstrate that by getting down to a little example here. First I'm going to call this one, put its name in there as a comment. Now what I'm going to do it I am going to create something what's called global variables. A global variable is a variable that can be use anywhere in a sketch, even if you have got a million lines of code, that variable can be used anywhere. A local variable is one that has a constrained scope. It can only be used in part of a sketch. For instance, within a blog of…

Contents