First version:
fun main(args: Array<String>) { val providers = Providers() val details = providers.getAllProviders() details.forEach { detail -> println("${detail.providerName}, ${detail.name}") } }
Second version: Replace 'detail' with 'it':
fun main(args: Array<String>) { val providers = Providers() val details = providers.getAllProviders() details.forEach { println("${it.providerName}, ${it.name}") } }
'Detail' is a Data Class, we can just print it:
Third version:
fun main(args: Array<String>) { val providers = Providers() val details = providers.getAllProviders() details.forEach(::println) }