https://kotlinlang.org logo
Title
t

tulio

06/27/2017, 7:46 PM
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

agomez

06/27/2017, 7:47 PM
tulio: you need to import to be able to use them
t

tulio

06/27/2017, 7:48 PM
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

arocnies

06/27/2017, 7:49 PM
If I remember correctly, extension functions are compiled to static methods with the first param as the receiver.
a

agomez

06/27/2017, 7:49 PM
besides you can use String::isNullOrEmpty
is a kotlin extension function on string instead of guava strings
t

tulio

06/27/2017, 7:50 PM
Nice, I will take a look 🙂
I will declare this functions inside the data class for now
a

alwyn

06/27/2017, 7:51 PM
other classes in same package?
a

agomez

06/27/2017, 7:51 PM
to use it from java you need to call as static method defined in YourFileNameKt class
t

tulio

06/27/2017, 7:51 PM
I understood Alejandro
@alwyn no
a

alwyn

06/27/2017, 7:52 PM
maybe they're just not open?
a

agomez

06/27/2017, 7:52 PM
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

arocnies

06/27/2017, 7:53 PM
Funnily enough, the extensionFunction(receiver, params...) way of calling an extension function works in both Kotlin and Java
a

agomez

06/27/2017, 7:54 PM
sure, if it works in java makes sense to work in kotlin