diff --git a/doc.go b/doc.go index d60e69bc..24f3ea58 100644 --- a/doc.go +++ b/doc.go @@ -66,15 +66,17 @@ // used, however, to create the unit of 'Slide', because in this case slide // is just a measurement of area. Instead, a constant could be defined. // const Slide unit.Area = 0.001875 // m^2 +// var WhiteBloodCellDim unit.Dimension // func init(){ -// WhiteBloodCellDim := unit.NewDimension() +// WhiteBloodCellDim = unit.NewDimension() // } // type WbcPerArea float64 // func (w WbcPerArea) Unit() *Unit{ -// return NewUnit(w, Dimensions{WhiteBloodCellDim: 1, LengthDim: -2}) +// return unit.NewUnit(float64(w), unit.Dimensions{WhiteBloodCellDim: 1, unit.LengthDim: -2}) // } // func main(){ -// // Add in something about using Unit +// v := WbcPerArea(15) +// fmt.Println(v.Unit()) // } // Please note that Unit cannot catch all errors related to dimensionality. // Different physical ideas are sometimes expressed with the same dimensions diff --git a/unittype.go b/unittype.go index 0b515a15..a0a8f678 100644 --- a/unittype.go +++ b/unittype.go @@ -35,6 +35,8 @@ type Dimensions map[Dimension]int var lastCreatedDimension Dimension = lastPackageDimension var newUnitMutex *sync.Mutex = &sync.Mutex{} // so there is no race condition for dimension +//var dimensionStrings map[Dimension]string = make() + // NewDimension returns a new dimension variable which will have a // unique representation across packages to prevent accidental overlap. // NewDimension should only be called for unit types that are orthogonal