

You can read the initial proposal and discussion in this YouTrack issue from 2015 (by Damian Wieczorek). Some time ago, even before Kotlin was released in version 1.0, individuals noticed that extension functions are great but could become even more powerful by allowing not only a single but multiple receivers. Making this a member function of a different class adds even more context to that function as it can only be called from the context of the enclosing class. With an extension function, you specify a receiver object that this function can be called on. We already know extension functions that are highly relevant in this article's setting. Adding context to Kotlin functions was possible even before context receivers entered the game. The language makers decided to come up with a prototype to demonstrate the design proposal solving the highly popular use case of adding context to Kotlin functions. Over a year ago, in February 2022, when Kotlin 1.6.20 was released, the language introduced context receivers for the first time. If you need to perform frequent lookups or modifications, a different data structure such as a hash table or a binary tree may be more appropriate.Why Kotlin needs Context Receivers and how to use them

DevOps Engineering - Planning to Production.Python Backend Development with Django(Live).


Android App Development with Kotlin(Live).Full Stack Development with React & Node JS(Live).Java Programming - Beginner to Advanced.Data Structure & Algorithm-Self Paced(C++/JAVA).Data Structure & Algorithm Classes (Live).
