Skip to content

✨ Add Quantity.From/TryFromUnitAbbreviation #1265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2023
Merged

Conversation

angularsen
Copy link
Owner

@angularsen angularsen commented Jun 17, 2023

Fixes #1252

Adds a naive implementation for creating a quantity given a value and a unit abbreviation.

However, there is a significant risk of failing due to multiple units from different quantities having the same unit abbreviation.
Matching is case-sensitive.

Changes

  • Add Quantity.FromUnitAbbreviation
  • Add Quantity.TryFromUnitAbbreviation
  • Add tests
  • Add example to README

Fixes #1252

Adding a naive implementation for creating a quantity given a value and a unit abbreviation.
There is a significant risk of getting `AmbiguousUnitParseException` due to units from different quantities having the same unit abbreviation.

### Changes
- Add `Quantity.FromUnitAbbreviation`
- Add `Quantity.TryFromUnitAbbreviation`
- Add tests
@angularsen angularsen merged commit ee96b4f into master Jun 17, 2023
@angularsen angularsen deleted the agl/fromunitabbrev branch June 17, 2023 00:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant