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

Length.squared and Length.cubed are ambiguous APIs #29

Open
kevincianfarini opened this issue Jan 2, 2025 · 2 comments
Open

Length.squared and Length.cubed are ambiguous APIs #29

kevincianfarini opened this issue Jan 2, 2025 · 2 comments
Labels
breaking change enhancement New feature or request
Milestone

Comments

@kevincianfarini
Copy link
Owner

kevincianfarini commented Jan 2, 2025

"3 meters squared" -- is this 9m2 or 3m2?

@kevincianfarini kevincianfarini added this to the 0.2.0 milestone Jan 2, 2025
@sargunv
Copy link

sargunv commented Jan 27, 2025

Imo the following is intuitive enough that .squared and .cubed aren't necessary:

val length = 3.meters
val area = length * length
val volume = length * length * length // or area * length

and then, for units:

val area = 9.squareMeters
val volume = 27.kiloliters

@kevincianfarini
Copy link
Owner Author

I like the suggestion to go with

val area = 1.square[Unit]
val volune = 1.cubic[Unit]

The original motivation for squared and cubed was to avoid complex unicode characters in source code. Eg.

val area = 1.meters²

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants