Course of Raku / Objects, I/O, and exceptions / Classes and objects / Classes / Exercises

Defined or not

Problem

Define two empty classes, Cat and Dog. Then loop over the four values Cat, Dog, Cat.new, and Dog.new, printing whether each one is defined. Notice that the two type objects are undefined and the two instances are defined — regardless of which class they belong to.

Example

The program prints:

False
False
True
True

Solution

See the solution

Course navigation

Quiz — Classes   |   Solution: Defined or not