Why is my kotlin extension function not being recognized?
Example:
// Defining extension function outside the class
fun String.greet(): String {
return "Hello, $this"
}
println("World".greet())
Solution:
// Ensure that the file containing the extension function is imported where it's used
import path_to_file_containing_extension.*
println("World".greet())
Make sure that you've imported the file containing the extension function in the file where you're trying to use it.