HaloO,

Brandon S. Allbery KF8NH wrote:
What if you want to store a modification of the value? e.g. compatibility method to set a length in inches when the stored length is in millimeters.

As outlined in my afterthought:

   class Length
   {
       has Num $.mm is rw = 0;
       method inch
       {
           yield $inch = $.mm * 25.4;
           self.mm = $inch / 25.4;
       }
   }

Would you regard that as elegant?

Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to