Changed method arguments to be more clear

This commit is contained in:
btracey
2013-10-09 12:02:16 -07:00
parent 60a7fa0433
commit 0735549733

View File

@@ -113,14 +113,14 @@ func NewUnit(value float64, d Dimensions) *Unit {
} }
// DimensionsMatch checks if the dimensions of two Uniters are the same // DimensionsMatch checks if the dimensions of two Uniters are the same
func DimensionsMatch(aU, bU Uniter) bool { func DimensionsMatch(a, b Uniter) bool {
a := aU.Unit() aUnit := a.Unit()
b := bU.Unit() bUnit := b.Unit()
if len(a.dimensions) != len(b.dimensions) { if len(aUnit.dimensions) != len(bUnit.dimensions) {
return false return false
} }
for key, val := range a.dimensions { for key, val := range aUnit.dimensions {
if b.dimensions[key] != val { if bUnit.dimensions[key] != val {
return false return false
} }
} }
@@ -129,8 +129,8 @@ func DimensionsMatch(aU, bU Uniter) bool {
// Add adds the function argument to the reciever. Panics if the units of // Add adds the function argument to the reciever. Panics if the units of
// the receiver and the argument don't match. // the receiver and the argument don't match.
func (u *Unit) Add(aU Uniter) *Unit { func (u *Unit) Add(uniter Uniter) *Unit {
a := aU.Unit() a := uniter.Unit()
if !DimensionsMatch(u, a) { if !DimensionsMatch(u, a) {
panic("Attempted to add the values of two units whose dimensions do not match.") panic("Attempted to add the values of two units whose dimensions do not match.")
} }
@@ -145,8 +145,8 @@ func (u *Unit) Unit() *Unit {
// Mul multiply the receiver by the unit changing the dimensions // Mul multiply the receiver by the unit changing the dimensions
// of the receiver as appropriate // of the receiver as appropriate
func (u *Unit) Mul(aU Uniter) *Unit { func (u *Unit) Mul(uniter Uniter) *Unit {
a := aU.Unit() a := uniter.Unit()
for key, val := range a.dimensions { for key, val := range a.dimensions {
u.dimensions[key] += val u.dimensions[key] += val
} }
@@ -156,8 +156,8 @@ func (u *Unit) Mul(aU Uniter) *Unit {
// Div divides the receiver by the argument changing the // Div divides the receiver by the argument changing the
// dimensions of the receiver as appropriate // dimensions of the receiver as appropriate
func (u *Unit) Div(aU Uniter) *Unit { func (u *Unit) Div(uniter Uniter) *Unit {
a := aU.Unit() a := uniter.Unit()
u.value /= a.value u.value /= a.value
for key, val := range a.dimensions { for key, val := range a.dimensions {
u.dimensions[key] -= val u.dimensions[key] -= val