Skip to content

Commit

Permalink
* fix BaseDimensions.IsBaseQuantity with single LINQ
Browse files Browse the repository at this point in the history
  • Loading branch information
ygorshkov committed Oct 23, 2024
1 parent 7eafae3 commit 0df7b6b
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions UnitsNet/BaseDimensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,7 @@ public BaseDimensions(int length, int mass, int time, int current, int temperatu
public bool IsBaseQuantity()
{
var dimensionsArray = new[] { Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity };
bool onlyOneEqualsOne = false;
foreach (var dimension in dimensionsArray)
{
if (1 == dimension)
{
if (onlyOneEqualsOne)
{
return false;
}
onlyOneEqualsOne = true;
}
else if (0 != dimension)
{
return false;
}
}
bool onlyOneEqualsOne = 1 == dimensionsArray.Select(d => d is 0 or 1 ? d : 2).Sum();
return onlyOneEqualsOne;
}

Expand Down

0 comments on commit 0df7b6b

Please sign in to comment.