https://kotlinlang.org logo
#announcements
Title
# announcements
l

LastExceed

06/09/2020, 11:03 AM
::main
in line 4 gives a an overload resolution ambiguity. I understand why it happens, but how do i resolve it? (i'd like to know the solution to both scenarios)
b

bezrukov

06/09/2020, 11:25 AM
just specify a type for x
👍 1
Copy code
val main = 42

fun main() {
	val x: KProperty0<Int> = ::main 
}
should be ok
e

elizarov

06/09/2020, 1:31 PM
Using lambda is easy:
Copy code
val x = { main } // reference property
val x = { main() } // reference function
3 Views