Variables that are defined inside of a function are only available to be used inside of that function. These are called local variables, and in general they are good to use because they get garbage collected once the function ends (sort of). Local variables would make a good choice should only be used on temporary variables, intermediate calculations, and things that aren't needed later in the program. Here's an example where material is a local variable:
Just define a variable outside of a function but inside of the class, and it will be available inside of all function in that class. In the example below, the variable material is now available throughout the entire class:
The posts on this site are written and maintained by Jim Lynch. About Jim...