Android App Development
iOS App Development
Flutter App Development
Cross Platform App Development
Hire on-demand project developers and turn your idea into working reality.
Big thanks to Webkul and his team for helping get Opencart 3.0.3.7 release ready!
Deniel Kerr
Founder. Opencart
Top Partners
Kotlin Scope functions
The Kotlin standard library contains several functions that are used for executing a block of code within the context of an object. When you call such a function on an object with a lambda expression provided, it forms a temporary scope. Here, we will check five of them:-
kotlin let:-
Kotlin let is a scoping function wherein the variables declared inside the expression cannot be used outside. let takes the object it is invoked upon as the parameter and returns the result of the lambda expression.
the key ‘it’ keyword contains a copy of the property inside let.
Kotlin run:-
Kotlin run is another interesting function. The following example demonstrates its use cases.
Kotlin also:-
As the name says, also expressions do some additional processing on the object it was invoked. Unlike let, it returns the original object instead of any new return data. Hence the return data has always the same type.
Like let, also uses it too.
Kotlin apply:-
Kotlin apply is an extension function on a type. It runs on the object reference (also known as the receiver) into the expression and returns the object reference on completion.
Kotlin with:-
Like apply, this is used to change instance properties without the need to call dot operator over the reference every time.
You can get more information regarding the scope functions and their uses in the following link:-
https://kotlinlang.org/docs/reference/scope-functions.html
Your email address will not be published. Required fields are marked*
Name*
Email*
Save my name email and website in this browser for the next time I comment.
Be the first to comment.
We use cookies to personalize your experience. By continuing to visit this website you agree to our use of cookies. Learn more about privacy policy
It was a successful collaboration. The Mobikul team provided the client everything they needed in a timely and high-quality manner. They were very professional, reliable, and accessible during the entire process. The client also saw no room for any improvements in the vendor's performance.
Vincenzo Carrano
Administrator, Segshop
USA
India
Global
Name
Email
Enquiry or Requirement
If you have more details or questions, you can reply to the received confirmation email.