There's a lot going on that's not obvious at first.

Note that ->contents() can either be passed an ID to return a particular content object from the container, or be passed nothing to return an object representing all contained objects. The Saucepan class has a few convenience methods that automatically generate such an object and do the work on it: $pan->melt is just shorthand for $pan->contents()->melt; same with $pan->bubble.

The Cookie::Sheet class is more generic and doesn't have such methods, since they could cause confusion. Note the $sheet->contents()->state( "cool" ) call; state iterates over each object contained in the object returned by contents() and verifies that they are all "cool". $sheet->state( "cool" ) just checks that the sheet itself is cool; some of it's contents may still be hot.

Another nice thing is the Ingredient class; it's constructor can take a quantity or it can return a lazy object whose quantity is undetermined until it's actually used in a quantized context, e.g. $sheet->spread( Ingredient->new( "crackers", type => "saltine" ),


In reply to Re^3: Saltine::Toffee by ysth
in thread Saltine::Toffee by ysth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.