September 22, 1999 Strong Typing Slide #36

Compile-Time Type Checking

Data structure:

        $octopus = 
          [ { tentacles => 1, hearts => 2, favorite_food => 3 },
            8,
            3,
            "crab cakes",
          ];

Usage:

        $octopus->{tentacles};             # Yields 8
        $octopus->{noses} = 1;             # Run-time error
                No such array field at ...


Next Copyright © 1999 M-J. Dominus