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

How to have a type literal #2

Open
jdimeo opened this issue Mar 27, 2020 · 0 comments
Open

How to have a type literal #2

jdimeo opened this issue Mar 27, 2020 · 0 comments

Comments

@jdimeo
Copy link

jdimeo commented Mar 27, 2020

One of my methods always returns a double regardless of the dimension (a ratio of overlap of two boxes, which is between 0.0 and 1.0 regardless of if the boxes are int, float, etc.

The last line of my method is

return ox * oy / getArea();

If the dimension is already a double, no problem. If it's an int or long, I need to cast area first so that it doesn't do integer division. How do I inject a (double) getArea() into the template but only when the dimension is not a double?

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