Skip to content

Commit ba1f343

Browse files
committed
removing erroneous use of TODO from zero() function, plus small QOL cleanup
1 parent c16b37e commit ba1f343

File tree

1 file changed

+7
-3
lines changed
  • core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl

1 file changed

+7
-3
lines changed

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/impl/Utils.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ internal fun <T> Iterable<T>.anyNull(): Boolean = any { it == null }
121121
internal fun emptyPath(): ColumnPath = ColumnPath(emptyList())
122122

123123
@PublishedApi
124-
internal fun <T : Number> KClass<T>.zero(): T =
124+
internal fun <T : Number> KClass<T>.zeroOrNull(): T? =
125125
when (this) {
126126
Int::class -> 0 as T
127127
Byte::class -> 0.toByte() as T
@@ -131,10 +131,14 @@ internal fun <T : Number> KClass<T>.zero(): T =
131131
Float::class -> 0.toFloat() as T
132132
BigDecimal::class -> BigDecimal.ZERO as T
133133
BigInteger::class -> BigInteger.ZERO as T
134-
Number::class -> 0 as T
135-
else -> TODO()
134+
Number::class -> 0 as? T
135+
else -> null
136136
}
137137

138+
@PublishedApi
139+
internal fun <T : Number> KClass<T>.zero(): T =
140+
zeroOrNull() ?: throw NotImplementedError("Zero value for $this is not supported")
141+
138142
internal fun <T> catchSilent(body: () -> T): T? =
139143
try {
140144
body()

0 commit comments

Comments
 (0)