Kotlin Extension Functions & Inline Functions | Cheezycode #36

preview_player
Показать описание
In this tutorial, learn what are extension functions and how to define them. It is useful when you want to extend the functionality of a class by adding members external to the class. Inline functions are defined by just adding an inline keyword before the function declaration. It improves performance by reducing the number of objects created. Behind the scenes, Kotlin creates a class and instance for lambdas which can impact the performance if we use a large number of lambdas. You can use the inline keyword to improve its performance. What it does is - Just copy paste the body of the function wherever it is called. This tutorial is part #36 of Kotlin Programming For Beginners Series. Learn Object Oriented Programming in Kotlin. Everything is explained in Hindi. Brief topics covered -

1. What are extension functions?
2. How to define the extension function in Kotlin?
3. Disadvantages of defining lambdas
4. Improve performance by marking functions as inline in Kotlin
5. Compare bytecode of the functions with or without inline keyword

Learn all this in Hindi (हिंदी में )

Kotlin Lambda Expression and Lambda Functions -

Kotlin Beginners Tutorial Series -

For more info - visit below link

We are social. Follow us at -
Рекомендации по теме
Комментарии
Автор

Wah... Great knowledge in few minutes.. Good job

ajaykumarvishwakarma
Автор

4:44 how can we pass loop fun to CalculateTimeAndRun? because CalculateTimeAndRun in its parameter is taking a function that does not take any argument (fn: ()-> Unit))

zdiscover
Автор

Dear sir you have covered a lot of things in kotlin in a very awsome way but some topics are still untouched by you like covariance and contravariance. Without these concept it feels like something is missing in kotlin and these concept may be utilised in android app development if
the requirement arises. So I kindly request you to pls make videos on it. If you don't have time it's ok, no issue

mojeebhasan
Автор

So, should we always use "inline", when we use lambda functions ??

ajaykotiyal
Автор

What if i am calling function 1000 so is it will copy and paste 1000 times?

sanketthakare
Автор

bro please use white cursor it wont visible inside black background..

vinayakhiremath
Автор

the class is created only for lamda or normal function as well please confirm ?

priyagupta
Автор

4:46 yahan agar loop() ke baad print statement likhe toh vo pehle execute ho rahi hai. can you please explain why?
Input:
calculateTime(10) {

println("lets rock")
}

output: lets rock
2 ms

TheAbhidugar
Автор

Please change your editor background from black to white.. I know working on black screen is very cool and feel like good but we are not watching perfectly...

rehanmunir
Автор

So can we make every function inline ?

priyagupta
Автор

fun Int.isEven(int: Int): Boolean {
return int % 2 == 0

}

calling the above function is not getting called in android activity it is saying not function found

my_love_sanatan
Автор

I came from a swift background and I found kotlin and swift very much similar.

PrakashChAwal
Автор

Sir ji, android me kuchh tufani leke aana....okk..?

raokarampal
visit shbcf.ru