Hexa
03/17/2019, 9:19 AMgetProperty
function in this case be best declared inline
? fun main() {
val someHashMap = mapOf("first" to Account1("test", "1234"))
println(getProperty("first") {someHashMap.getValue(it).number})
}
fun getProperty(name: String, action: (String) -> String) : String{
return action(name)
}
class Account1(val name: String, val number: String)
I checked the decompiled Java bytecode but I can't work out why inline is better? Is it because in the none-inline
it calls the getProperty
function in the main
like in here? https://gist.github.com/rinnegan/4233b6a242b5f2864e0737b186b45df7#file-inline-vs-none-inline-L33karelpeeters
03/17/2019, 9:41 AMFunction
created for every call, in the inline one that isn't necessary.Hexa
03/17/2019, 10:02 AM(Function1)(new Function1()
?karelpeeters
03/17/2019, 10:58 AM