I am trying to learn some kotlin since most of Android development is moving to the kotlin language. I have a sample code that I was trying to solve in kotlin
class City(val country: String, val name: String, val population: Int)
fun main(args: Array<String>) {
val cities = arrayOf<City>(
City(country = "USA", name = "Boston", population = 2500000000),
City(country = "China", name = "Beijing", population = 100000000),
City(country = "USA", name = "Atlanta", population = 6000300)
)
printCitiesByCountry(cities);
I need to write a function printCitiesByCountry(cities) that returns sample :
- USA = [Boston = 250000000, Atlanta = 6000300]
- China = [Beijing = 100000000]
How can I achieve this.