use function
-
kotlin use exampleAndroid 외 개발 2019. 12. 10. 13:44
변경 전 val cursor: Cursor = readableDatabase.rawQuery(sql, null) while (cursor.moveToNext()) { } cursor.close() 변경 후 readableDatabase.rawQuery(sql, null)?.use { while (it.moveToNext()){ } } https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/use.html use - Kotlin Programming Language kotlinlang.org