Trong Kotlin, tôi có thể thực hiện khởi tạo lười biếng mà không có tham số như khai báo bên dưới.Cách khởi tạo Lazy với tham số trong Kotlin
val presenter by lazy { initializePresenter() }
abstract fun initializePresenter(): T
Tuy nhiên, nếu tôi có một tham số trong initializerPresenter tôi ví dụ viewInterface
, làm thế nào có thể tôi vượt qua các tham số vào Lazy Initiallization?
val presenter by lazy { initializePresenter(/*Error here: what should I put here?*/) }
abstract fun initializePresenter(viewInterface: V): T
Cảm ơn bạn rất nhiều! – Elye
Tôi thích cách bạn phù hợp với cả ba khả năng thành một ví dụ về mã. –