https://kotlinlang.org logo
#announcements
Title
# announcements
j

jw

08/30/2017, 3:49 PM
why are you not using nullable types?
s

supaham

08/30/2017, 3:49 PM
Because some fields can be nullable, but not present. This is used for db reads/writes, and what i do is just push the DAO and it knows which fields to populate the query with
r

rook

08/30/2017, 6:15 PM
then your code should probably look like:
Copy code
data class SquadEntry(
    val name: String,
    var leader: UUID? = null,
    .....
    var members: Set<UUID>? = null
)
Then if your fields aren’t present, they default to null and are already wrapped, instead of needing the
OptionalPresence
wrapper.
s

supaham

08/30/2017, 7:08 PM
And what if leader can be null @rook?
as in, present with the value of null
r

rook

08/30/2017, 8:27 PM
It seems counterproductive to track a custom null state of something. What’s the limitation of treating it simply as null?
👍 1
v

villela

08/30/2017, 10:33 PM
his null means filling the db entry with null, empty means leave as it was before (or it is the opposite), only changing fields that were set
3 Views