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.





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

Recommended from Medium

Make Oh My Zsh history play nicely with WebStorm / IntelliJ

Symfony environment setup without Vagrant or Docker (OSx)

Task 7.1. (A): 🔅Integrating LVM with Hadoop and  providing Elasticity to DataNode Storage

Parallelism(and concurrency) in Node.js and Python and Golang and comparison them — Part 1

Bitrise- Flavor Wise Workflow for Flutter Integration Part-2

Shakabrah (PGPlay) Writeup

Application Centric Backup and Restore on OpenShift Platform using OADP

OmniFlix Network — Community Update 33

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


More from Medium

Android Intents and Single Login Per Class— Kotlin

Kotlin Multiplatform: Static Library without Cocoapods

How Jetpack Compose works?