Next / Previous / Contents / Shipman's homepage

27.3. FoDim.__add__()

Addition of two FoDim instances happens in two steps. First we convert the augend to the same type as self, then simply add their numbers.

fosox.py
# - - -   F o D i m . _ _ a d d _ _

    def __add__(self, other):
        '''Add two dimensions.
        '''
        #-- 1 --
        # [ otherCon  :=  other expressed in units of (self.units) ]
        otherCon = other.convert(self.units)

        #-- 2 --
        return FoDim(self.n + otherCon.n, self.units)