See primary documentation in context for Overriding default gist method
Some classes might need their own version of
gist, which overrides the terse way they are printed when called to provide a default representation of the class. For instance, exceptions might want to write just the
payload and not the full object so that it is clearer what to see what's happened. However, this isn't limited to exceptions; you can do that with every class:
my = Cook.new(utensils => <spoon ladle knife pan>,cookbooks => ['Cooking for geeks','The French Chef Cookbook']);say Cook.gist; # OUTPUT: «⚗Cook⚗»say .gist; # OUTPUT: «⚗ Cooks with spoon ‣ ladle ‣ knife ‣ pan using «Cooking for geeks» and «The French Chef Cookbook»␤»
Usually you will want to define two methods, one for the class and another for class instances; in this case, the class method uses the alembic symbol, and the instance method, defined below it, aggregates the data we have on the cook to show it in a narrative way.