Sign in Go Pro


Delegation Using Lazy Functions


Up next


Course Retired

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


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.




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

You need to go PRO to post comments.

Lessons in Kotlin