Skip to content

Commit

Permalink
Bake in ext fun
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed May 17, 2024
1 parent 6ec2295 commit 79f8e45
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import org.joda.time.DateTime

@Parcelize
data class Device(val id: DeviceId, private val name: String, val created: DateTime) : Parcelable {
fun displayName(): String = name.capitalizeFirstCharOfEachWord()
}

private fun String.capitalizeFirstCharOfEachWord(): String {
return split(" ")
.joinToString(" ") { word -> word.replaceFirstChar { firstChar -> firstChar.uppercase() } }
.trimEnd()
fun displayName(): String =
name
.split(" ")
.joinToString(" ") { word ->
word.replaceFirstChar { firstChar -> firstChar.uppercase() }
}
.trimEnd()
}

0 comments on commit 79f8e45

Please sign in to comment.