Ellen Spertus
06/25/2025, 6:00 PM// 1
val numAdded = api.addNote(
modelId,
deckId,
fields,
tags = setOf(crn)
)
return numAdded == 1
// 2
return api.addNote(
modelId,
deckId,
fields,
tags = setOf(crn)
).let {
it == 1
}
// 3
return api.addNote(modelId, deckId, fields, tags = setOf(crn)) == 1Joffrey
06/25/2025, 6:02 PMCLOVIS
06/27/2025, 9:33 AMoligarchokapi
06/27/2025, 12:26 PMzhuinden
10/22/2025, 9:08 AMphldavies
10/22/2025, 11:12 AMreturn keyword.
I'd also query whether the condition should be >= 1 assuming the function is intended to return a boolean indicating whether a note was added or not. Should it ever add more than one it would currently return false.
The formatting difference between 1 and 3 makes 3 seem much more succinct than 1 but there's really not much in it when formatting similarly:
// 1
val numAdded = api.addNote(modelId, deckId, fields, tags = setOf(crn))
return numAdded == 1
vs
// 3
return api.addNote(modelId, deckId, fields, tags = setOf(crn)) == 1
You could also flip the condition to bring it closer to the return and therefore more obvious on a cursory read.
// 3b
return 1 == api.addNote(modelId, deckId, fields, tags = setOf(crn))