Why with function is not an Extension to Template class?

After reading my last blog about Kotlin with function, a lot of developers have asked me about, why with is not an extension to Template class like other scope functions?

This post was originally posted at https://agrawalsuneet.github.io/blogs/why-with-function-is-not-an-extension-to-template-class/ and reposted on Medium on 5th June 2021.

Not only with, but run also has two implementations among which one is not an extension to Template class but a generic extension function.

The question is why?

with is an extension to generic class means it is not specific to any class. This could have been an extension to Any class which is the base class for all the classes, similar to java.lang.Object class in Java, even if you extend it or not. Or this could have been added as an extension to Template class which is compatible with Java objects also.

Please continue reading at https://agrawalsuneet.github.io/blogs/why-with-function-is-not-an-extension-to-template-class/

That’s all for now. You can read my other interesting posts here or you can enjoy my games or apps listed here. Feel free to use my open-source Android components in your app listed here. Or drop an email, if you didn’t find what you are looking for and need some help.

--

--

--

https://agrawalsuneet.github.io/

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Basic Android Notification

Uno Pc

Uno

GMA & PokeMine Airdrop Rewards Event in AMA

God Activity Architecture — One Architecture To Rule Them All

DataStore Android -How to use it like a pro using Kotlin

Activity Lifecycle Cheat Sheet

How To make an APP

What Goes Around Comes Around

Ferris wheel

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Suneet Agrawal

Suneet Agrawal

https://agrawalsuneet.github.io/

More from Medium

Kotlin ⚡️: Null Safety | Erselan Khan

Kotlin: Scope Functions

Reduce, Reuse & Recycle your thread pools ♻️

Diving deep into Kotlin Coroutines.