leonhardt
09/28/2023, 7:00 PMset
and modify
operations are used with nullable properties, the functions do not accept nullable values where I would expect them.import arrow.optics.copy
import arrow.optics.optics
@optics
data class Person(val name: String?) {
companion object
}
fun main() {
val person = Person(name = "Matt")
person.copy {
// this does not compile, not able to return null:
Person.name.transform { if (it.isNullOrBlank()) null else it.trim() }
// even this does not compile, not able to pass null:
Person.name.set(null)
}
}
Kev
09/30/2023, 9:38 AMleonhardt
10/01/2023, 6:00 AMGemy
10/01/2023, 2:25 PMleonhardt
10/04/2023, 7:22 AMAlejandro Serrano.Mena
10/04/2023, 7:28 AMnullableField
now you write nullableField.notNull
in 2.0). Alas, this is a big breaking change, this is why we decided against including it in the (backwards-compatible) 1.2
We’re happy to discuss other migration strategies which would give users this feature, yet not invalidate any code from previous versionsleonhardt
10/04/2023, 7:45 AMAlejandro Serrano.Mena
10/04/2023, 7:50 AMleonhardt
10/04/2023, 8:09 AM