Kotlin Tutorial - Inline Functions
Автор: JOMO Developer
Загружено: 2020-09-25
Просмотров: 491
Kotlin inline functions are equivalent to inline refactoring i.e. instead of calling the function, the contents of the function are inlined. This helps in avoiding an extra function call but leads to expanded code.
Inline functions can also help improve performance when we use lambdas. Kotlin lambdas help in writing a very clear and concise code. Java equivalent of Kotlin is efficient in most of the cases. There can be some specific scenarios in which using lambdas can have some performance implications and in these cases, inline functions can be helpful.
Java equivalent of Kotlin Lambda is a "Java Class" with a "single invoke function". A new instance of the class is created and its invoke method is called. In most of the cases, the compiler will try to create a single instance of the class, but in some cases, it will create a new instance every time the lambda is passed. Let's look at some code that will bring some clarity
00:00 - Intro
00:50 - Example 1 - Normal function call
03:08 - Example 1 - Inline function call
06:02 - Example 2 - Normal function call
09:27 - Example 2 - Inline function call
Доступные форматы для скачивания:
Скачать видео mp4
-
Информация по загрузке: