logo
  • 教程列表
  • SO官方文檔
  • 委託屬性
    • 可觀察的屬性
    • 定製授權
    • 延遲初始化
    • 地圖支援的屬性
    • 委託可以用作減少樣板的圖層
  1. StackOverflow 文件
  2. Kotlin 教程
  3. 委託屬性
  4. 定製授權

定製授權

Created: November-22, 2018

class MyDelegate {
    operator fun getValue(owner: Any?, property: KProperty<*>): String {
        return "Delegated value"
    }
}

val foo : String by MyDelegate()
println(foo)

該示例列印 Delegated value

  • 延遲初始化
  • 可觀察的屬性

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明