kotools / types

Explicit types for Kotlin Multiplatform.
https://types.kotools.org
MIT License
89 stars 5 forks source link

✨ New `orNull(Double)` and `orThrow(Double)` in `Zero.Companion` #720

Open LVMVRQUXL opened 1 month ago

LVMVRQUXL commented 1 month ago

📝 Description

We want to add experimental overloads for the Zero.Companion.orNull and the Zero.Companion.orThrow methods, for creating an instance of the Zero type from the specified Double number.

Here's the Application Programming Interface (API) goal of this issue:

interface Zero {
    companion object {
        fun orNull(number: Double): Zero?
        fun orThrow(number: Double): Zero
    }
}

These factory methods should be available for all platforms, except for the orNull method that shouldn't be accessible from Java, due to its non-explicit support for nullable types.

✅ Checklist

See the Issue implementation section in the contributing guidelines before addressing the following checklist.