fun getAllProviders(fn: (String, String) -> Unit) { // Unit is just like void val allProviders = Providers.getProviders() val it = allProviders.iterator() while(it.hasNext()) { provider.forEach { key, value -> fn(key.toString(), value.toString()) } } } fun main(args: Array<String>) { getAllProviders { // when passing the value is a function, we use {} key, value -> println(" $key: $value") } }