Colton Idle
03/16/2022, 2:40 AM[FIRST]..[LAST]
Notice the two dots are supposed to show that there are two spaces. What's a convenient way of only having a single space?
private fun Person.prettyPrint() =
"${this.data.firstName} ${this.data.middleName} ${this.data.lastName}"
Adam Powell
03/16/2022, 2:50 AM.joinToString
, but also https://shinesolutions.com/2018/01/08/falsehoods-programmers-believe-about-names-with-examples/ 🙂Colton Idle
03/16/2022, 4:08 AMRichard Gomez
03/16/2022, 1:32 PMdata class Component(val type: String, val namespace: String? = null, val name: String, val version: String) {
val displayName: String by lazy { if (namespace != null) "$namespace:$name" else name }
}
ephemient
03/16/2022, 4:13 PMlistOfNotNull(first, middle, last).joinToString(" ")
(or .takeIf { it.isNotEmpty() }
to make empty strings into null so that listOfNotNull
skips them) but yeah, human names definitely don't all fit that model