I have faced some weird thing from Java - method r...
# announcements
v
I have faced some weird thing from Java - method reference operator on an object like so:
RegexCompleter("SomeCoolRegexString", myHashMap::get)
. I've read from stackoverflow that Kotlin does not support method reference on objects. How to convert to Kotlin?
i
hmm…Below is the example of object (and class) method references. Hmm - does it cover you case?
Copy code
fun main(args: Array<String>) {
    val classFooMethodReference = Foo.Companion::doSth
    
    val companionFooMethodReference = Foo::companion::classdoSth
    
    val foo = Foo()
    val instanceFooMethodReference = foo::doSth
    
    val objectBarMethodReference = Bar::doSth
}

class Foo() {
    companion object {
        fun doSth() {
        
    	}
    }
    
    fun doSth() {
        
    }
}

object Bar {
    fun doSth() {
        
    }
}
v
Looks like it's ok. I need to resolve all the preceeding errors in the code 🙂
i
Could you share that link to stackoverflow where you have read it?
i
@ValV I think Ilya meant link to stack overflow post (with this information), not your code
I have just missed icon while reading
i
Seems that the answer is outdated since Kotlin 1.1, when the bound callable references were introduced https://kotlinlang.org/docs/reference/reflection.html#bound-function-and-property-references-since-11
v
Ah, I see