Kotlin 'when' statement vs Java 'switch'

前端 未结 10 1035
感情败类
感情败类 2020-12-03 06:41

Pattern matching in Kotlin is nice and the fact it does not execute the next pattern match is good in 90% of use cases.

In Android, when database is updated, we use J

10条回答
  •  有刺的猬
    2020-12-03 07:00

    val orders = arrayListOf(
                { upgradeFromV1()},
                { upgradeFromV2()},
                { upgradeFromV3()}
    )
    
    orders.drop(oldVersion).forEach { it() }
    

提交回复
热议问题