Overview¶
In Hello World, you called env.out.print("Hello, world!"). Why can you access out on env? The constructor declared env to be an Env, and that type defines the field. When you define a type of your own, you decide what other code can do with it.
In this chapter you’ll write a class that keeps track of a wombat’s hunger and an actor that can receive a message asking it to eat. You’ll also see how to describe alternatives. If a variable x might hold a string or have no string at all, you can give it the union type (String | None) and use None for the missing string.