Hey! Like how `Snackbar` class has a static functi...
# android
a
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
aakaashjois: Yes
a
Can you please tell me how I can do that?
k
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
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
fun Snackbar.something(){ // doing what you want }