sbyrne
10/19/2018, 2:12 PMAndreas Sinz
10/19/2018, 2:16 PMEgor Trutenko
10/19/2018, 2:18 PMlazy
in Kotlin is just a wrapper around underlying type, so basically if you want your variable to be lazy
, it needs to be Lazy<String>
. by
keyword just delegates get
function to something else (in this case - to Lazy
instance, which is acquired by calling by readWriteLazy...
.sbyrne
10/19/2018, 2:18 PMAndreas Sinz
10/19/2018, 2:32 PMAndreas Sinz
10/19/2018, 2:34 PMreadWriteLazy
come from?russhwolf
10/19/2018, 2:35 PMvar foo by readWriteLazy { "b" }
sbyrne
10/19/2018, 2:52 PMinternal fun <T> readWriteLazy(initializer: () -> T): ReadWriteProperty<Any?, T> = ReadWriteLazyVal(initializer)
sbyrne
10/19/2018, 2:53 PMsbyrne
10/19/2018, 2:53 PMsbyrne
10/19/2018, 3:02 PMEgor Trutenko
10/19/2018, 3:13 PMreadWriteLazy
returns wrapper around the value, which abstracts over access to this value, making it lazy. by
keyword just delegates access to this wrapper, leaving the value intactAndreas Sinz
10/19/2018, 3:40 PM