Local Variables

The last type of variable is the local. It is a variable, so we know that it is a storage location with a name where we can put values in and read them out. A local variable needs to be explicitly initialized, like a global, and uses orange getters and setters, also like a global. What makes this one different is that the scope of the variable is limited. You can actually control exactly what the scope is, and that’s both cool and useful. Take a look at a local variable block in Figure 4.16. Note the notches on the top and bottom. Those mean that it clicks into a stack of action blocks: setters, procedure calls, and so on. It also has the same notch inside it, where you can put more action blocks. In addition, you can see an ...

Get Learning MIT App Inventor: A Hands-On Guide to Building Your Own Android Apps 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.