7CREATING MODULES TO REUSE YOUR CODE

image

As your programs become more sophisticated, you might want to reuse code you’ve already written to save time. Fortunately, you can reuse your code as a module, which is a program that contains functions that other programs can call.

In this chapter, you’ll learn how to create custom functions and your own module. The turtles will need to run these functions in Chapter 8, so you’ll write functions your tree farmer turtles (and the turtles you make in later chapters) will load as a module.

CREATING FUNCTIONS WITH THE FUNCTION STATEMENT

To create your own functions, you use a function statement, which is made ...

Get Coding with Minecraft now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.