Skip to content
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

Swift Converter error: Incompatible units #135

Open
demilsson opened this issue Mar 8, 2023 · 0 comments
Open

Swift Converter error: Incompatible units #135

demilsson opened this issue Mar 8, 2023 · 0 comments

Comments

@demilsson
Copy link

I'm trying to set up a converter between the inverse units m/s and min/km (meters per second -> minutes per kilometer).

Using simple syntax, this works as expected and provides the correct result:

let qty = new Qty('1.9054 m/s');
let result = qty.to('min/km'); 

// result = 8.7470697316399

However, the same conversion using swiftConverter throws an error instead:

let qty = Qty.swiftConverter('m/s', 'min/km');
let result = qty(1.9054); 

// Throws QtyError: Incompatible units: m/s and min/km

Why can't the swiftConverter do the same conversion? It works for other, non-inverse conversions, so I guess the problem lies somewhere in there.

I use swiftConverter since my application converts hundreds of arrays with thousands of values.
Is there a way to work around this?

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

No branches or pull requests

1 participant