I want to thumbnail initials with two word for my image view like \"Peter Parker\" but am able to get only one word \"P\"while running code how can get second word after spa
You can do it functional way:
val peterParker = "Peter Parker" val initials = peterParker .split(' ') .mapNotNull { it.firstOrNull()?.toString() } .reduce { acc, s -> acc + s } println(initials) //PP
This would cover cases when a person's name consists of more than 2 words.