Skip to content

Commit

Permalink
Kotlin懒加载
Browse files Browse the repository at this point in the history
  • Loading branch information
BetterZhang committed Jun 28, 2017
1 parent 920d7b3 commit 19871a0
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/com/betterzhang/learnkotlin/kotlin/Lazy.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.betterzhang.learnkotlin.kotlin

/**
* Created by IntelliJ IDEA.
* Author : Andrew Zhang
* Email : betterzhang.dev@gmail.com
* Time : 2017/06/28 下午 2:08
* Desc : Kotlin懒加载
*/

val lazyValue: String by lazy {
println("init") // 第一次使用时才被初始化
"Hello Kotlin"
}

fun main(args: Array<String>) {
println(lazyValue)
println(lazyValue)
}

0 comments on commit 19871a0

Please sign in to comment.