9. Understanding Scope and Lifetime
What’s Scope?
In this chapter, you add an important building block to your programming foundation. Specifically, this chapter discusses when a variable or procedure is accessible to code in another procedure. Two interlocking concepts control which variables a procedure can use: the scope of a variable dictates its visibility to other code, and the lifetime of a variable dictates when it contains valid data. Although the examples use variables, the information in this chapter also applies to constants.
Most variables work within the confines of the procedure in which they’re declared. Sometimes you need ...
Get Business solutions Automating Microsoft now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.