A case statement selects behavior from a discriminant such as an animal's type. It can replace separate classes with data and one dispatching function, but changes then concentrate in that function. section 13.1
One greeting function, three cases
Represent a dog, cat, or cow as a map containing name and type, then switch on type to print the appropriate greeting. Invalid maps require explicit validation.
The design trade-off is straightforward:
- Changing one animal's behavior requires editing the shared dispatching code, unlike changing a class implementation. section 13.1








