I'm declaring this extension functions in the same...
# getting-started
t
I'm declaring this extension functions in the same file as the data class, but I'm unable to use them in other classes
a
tulio: you need to import to be able to use them
t
I'm trying to use them on a Java class... Maybe that's the problem
Probably the compiler won't generate code to simulate extensions in java
a
If I remember correctly, extension functions are compiled to static methods with the first param as the receiver.
a
besides you can use String::isNullOrEmpty
is a kotlin extension function on string instead of guava strings
t
Nice, I will take a look 🙂
I will declare this functions inside the data class for now
a
other classes in same package?
a
to use it from java you need to call as static method defined in YourFileNameKt class
t
I understood Alejandro
@alwyn no
a
maybe they're just not open?
a
being an instance of Task the first argument to that method
you can always inspect the bytecode inside idea to understand the generated code
a
Funnily enough, the extensionFunction(receiver, params...) way of calling an extension function works in both Kotlin and Java
a
sure, if it works in java makes sense to work in kotlin