Last active
December 19, 2023 02:48
-
-
Save dladukedev/e801176f8e8f08289e5e2f8be939b979 to your computer and use it in GitHub Desktop.
Kotlin Function Reference Ambiguity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class AdditionClass(val str: String, val num: Int) { | |
fun add(addStr: String): String { | |
return str + addStr | |
} | |
fun add(addNum: Int): Int { | |
return num + addNum | |
} | |
} | |
val addition = AdditionClass("Hello", 10) | |
// Compile Error! | |
val add = addition::add | |
// Success! | |
val addInt: (Int) -> Int = addition::add | |
// Still Compile Error! | |
val addString = addition::add as (String) -> String |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment