January 2018
Intermediate to advanced
434 pages
14h 1m
English
Extension functions are useful, as they allow us to extend the functionality of a class without actually touching it. For example, if you've used Glide or Picasso library for placing an image inside the Imageview, you must be familiar with the following code:
Glide.with(context).load(image_url).into(imageView)
We can make this look much better using an extension function. Let's call the loadImage(imageUrl) function on imageView. If you do it, you will see an error—Unresolved reference- loadImage:

You will also see two suggestions, one of which is Create extension function:
If you click on Create extension function, you'll ...
Read now
Unlock full access