Extension Functions: Motivation

An introduction to the problems that extension functions solve, why code isn’t written for computers anymore, and what that means for how we write code

Gabriel Shanahan
The Kotlin Primer

--

— — — — — — — — — — — — — — —

THE CURRENT VERSION OF THIS ARTICLE IS PUBLISHED HERE.

— — — — — — — — — — — — — — —

Tags: #FUNDAMENTAL CONCEPT

This article is part of the Kotlin Primer, an opinionated guide to the Kotlin language, which is indented to help facilitate Kotlin adoption inside Java-centric organizations. It was originally written as an organizational learning resource for Etnetera a.s. and I would like to express my sincere gratitude for their support.

It is recommended to read the Introduction before moving on. Check out the Table of Contents for all articles.

Extension functions are probably among the features of Kotlin which can be a little more difficult to grasp, for one simple reason — they don’t actually make writing any kind of code that much easier, apart from a small amount of sugar coating. They add form, not function. Because of this, it is often not clear when they should be used or why, and…

--

--