Skip to content

Commit 1219d9c

Browse files
author
David Motsonashvili
committed
improved null handling
1 parent e79db71 commit 1219d9c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

firebase-ai/src/main/kotlin/com/google/firebase/ai/type/ImagenGenerationResponse.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ internal constructor(public val images: List<T>, public val filteredReason: Stri
7070
val scores: List<Double>? = null
7171
) {
7272
internal fun toPublic(): Map<String, Double> {
73-
return categories?.zip(scores!!)?.toMap() ?: emptyMap()
73+
if (categories == null || scores == null) {
74+
return emptyMap()
75+
}
76+
return categories.zip(scores).toMap()
7477
}
7578
}
7679
}

0 commit comments

Comments
 (0)