Sign in Go Pro

Kotlin

Delegation Using Lazy Functions

 
Autoplay

Up next

Previous

Course Retired

The Introduction to Kotlin course has been retired and replaced with the very comprehensive Kotlin Programming Language course.

About

Delegation allows deferring the initialization of a variable at a later stage instead of initializing the variable as null. It helps to initialize the variable only once.

Fortunately, Kotlin comes with native support for Delegation with 2 standard delegates (part of the Kotlin standard library) via lazy and lateinit. This is extremely handy and useful feature, as we don’t need to initialize something until it is required; or just because we can’t initialize something until we have all we need.

In this lesson you will learn:
- How the lazy function work
- How values are only computed once
- About the various LazyThreadSafetyMode's that lazy supports.

Instructor

Links

Comments

There are no comments on this lesson, start the conversation below ...

>
You need to go PRO to post comments.

Lessons in Kotlin