https://kotlinlang.org logo
Title
a

aakaashjois

06/22/2017, 4:54 PM
Hey! Like how
Snackbar
class has a static function
make
which allows us to create a
Snackbar
, can I use Kotlin extension function on the
Snackbar
class to create a static method similar to
make
?
r

radityagumay

06/22/2017, 6:23 PM
aakaashjois: Yes
a

aakaashjois

06/22/2017, 6:41 PM
Can you please tell me how I can do that?
k

kirillrakhman

06/22/2017, 8:50 PM
You can do that for kotlin classes that have companion objects by writing extension functions for the companion object. You can't do that for Java classes
a

aakaashjois

06/23/2017, 3:56 AM
Thank you! I wanted to do it for the Snackbar class. I hope this feature gets implemented in the future for Java classes as well.
r

radityagumay

08/19/2017, 5:35 PM
fun Snackbar.something(){ // doing what you want }