You are currently viewing Class method reference in kotlin

Class method reference in kotlin

// could someone tell me how to create callable reference on member class. It work directly on for ex. Double::isFinite, but I need to pass instance of object in my own created class

class Hello { fun sayHello(s:String){ println(“$s”) } }

fun main() {

val isDFinite = Double::isFinite println(isDFinite(1.6)) // true val say = Hello::sayHello say("Good morning") // doesn't work say(Hello(),"Good morning") // it's work 

}

submitted by /u/corinastphn
[link] [comments]