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

feat!: change unit enums to objects #62

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

sargunv
Copy link

@sargunv sargunv commented Feb 3, 2025

prerequisite for #58

@sargunv sargunv marked this pull request as draft February 3, 2025 06:34
Comment on lines +24 to +48
public val Decimilliare: AreaUnit = object : AreaUnit {
override val symbol: String = "dma"
override val millimetersSquaredScale: Long = 100
}
public val Centiare: AreaUnit = object : AreaUnit {
override val symbol: String = "ca"
override val millimetersSquaredScale: Long = 1_000_000
}
public val Deciare: AreaUnit = object : AreaUnit {
override val symbol: String = "da"
override val millimetersSquaredScale: Long = 10_000_000
}
public val Are: AreaUnit = object : AreaUnit {
override val symbol: String = "a"
override val millimetersSquaredScale: Long = 100_000_000
}
public val Decare: AreaUnit = object : AreaUnit {
override val symbol: String = "daa"
override val millimetersSquaredScale: Long = 1_000_000_000
}
public val Hectare: AreaUnit = object : AreaUnit {
override val symbol: String = "ha"
override val millimetersSquaredScale: Long = 10_000_000_000
}
public val entries: List<AreaUnit> = listOf(Decimilliare, Centiare, Deciare, Are, Decare, Hectare)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might make sense to make all of these getters? Eg.

private val Decimilliare: AreaUnit get() = object : AreaUnit { ... }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I generally don't like that pattern because the objects lose their name and and become anonymous objects.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, on second thought -- I think we should pause this until #42 is complete. Each of these being anonymous objects is pretty awkward and this will likely significantly change once the work in the above issue is completed.

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.

2 participants