``` private val items : MutableList<String...
# getting-started
f
Copy code
private val items : MutableList<String> by lazy {
        // a lot of init code
    }
how do I exclude my initialisation code into a separate function? I can think of creating something like
Copy code
private val items : MutableList<String> by lazy {
        init()
}
fun init() : MutableList<String> {...}
but maybe there is more elegant way
d
You can use a function reference:
by lazy(::myFunction)
Or in this case,
by lazy(::init)
.
f
nice, thanks
but what if I need some params passed to the init func?
d
Then you need to actually call it
f
ah, ok
thanks anyway 🙂
d
You could use one of the existing FP libraries and then use
curry
. But I think that is a bit overkill here.