What class should include "5 kilograms"?

stan at stanheckman.com stan at stanheckman.com
Wed Nov 11 21:34:35 UTC 1998


I think subclassing Number was a good suggestion. Disabling only the
methods "asFloat" and "truncated" disabled most of the methods we don't
want for DimensionalNumbers, and none of those we do want.
And we get all sorts of methods that do the right thing for free, such
as the example below.

BasisUnit basisUnitsPoolHack.
BasisUnit loadBasisUnitsIntoSmalltalk.
massPerServing := 6 * Ounce.
 6.0 ounces
massPerContainer := 1 * Kilogram.
 1 kilogram
servingsPerContainer := massPerContainer // massPerServing.
 5
leftovers := massPerContainer \\ massPerServing.
 0.149515 kilograms

-- 
Stan





More information about the Squeak-dev mailing list