Rak
06/10/2018, 11:15 AMtipsy
06/10/2018, 12:49 PMikt
06/10/2018, 12:55 PMikt
06/10/2018, 1:10 PMbod
06/10/2018, 3:42 PMprivate lateinit var database: TestDatabase
fun get(context: Context): TestDatabase {
if (!::database.isInitialized) {
database = Room.databaseBuilder(context, TestDatabase::class.java, DATABASE_NAME).build()
}
return database
}
It's a trick I've seen elsewhere and it worked. But when I run it I get:
Caused by: java.lang.NoSuchFieldError: No field database of type Lcom/example/storage/db/TestDatabase; in class Lcom/example/storage/db/TestDatabase$Companion; or its superclasses (declaration of 'com.example.storage.db.TestDatabase$Companion' appears in /data/app/com.example.test-2/base.apk)
bod
06/10/2018, 3:43 PMfrellan
06/10/2018, 10:06 PMfor (i in 0 until listA.size) {
if (listB[i] == null || listC[i] == null) continue
val b = listB[i]
val c = listC[i]
}
In the above example, neither b
nor c
is smart casted to a non null variable. I am forced to do this:
for (i in 0 until listA.size) {
if (listB[i] == null || listC[i] == null) continue
val b = listB[i]!!
val c = listC[i]!!
}
Am I doing something wrong? Anybody encountered issues with smart cast and continue
?diesieben07
06/11/2018, 12:06 PM0rph3u
06/11/2018, 11:37 PMchansek
06/12/2018, 7:03 PMHullaballoonatic
06/12/2018, 7:35 PM1d12
in my code instead of 1 d 12
😛Shawn
06/12/2018, 7:36 PMHullaballoonatic
06/12/2018, 7:43 PMcompleting type inference
since I've tried importing precisely either of those functions, as well as being as specific with class types as possible, nothing changes, and it shouldn't matter anyways? Maybe I should just reinstall.Hullaballoonatic
06/12/2018, 7:55 PMsnowe
06/12/2018, 10:59 PMpniederw
06/13/2018, 12:13 AMchristophsturm
06/13/2018, 8:19 AMmichael.hunger
06/13/2018, 9:53 AMgetOrElse
in Array that just takes a literal default not like currently a function from index to value ?
I know you can do array.getOrNull(idx) ?: defaultValue
but it reads more verbosetemp_man
06/13/2018, 4:13 PMsnowe
06/13/2018, 4:28 PMrook
06/13/2018, 4:30 PMuser
06/13/2018, 8:48 PMchanghyun
06/14/2018, 5:33 AMslavasysoev
06/14/2018, 10:10 AMdstarcev
06/14/2018, 11:58 AMacando86
06/14/2018, 2:33 PMgreybird
06/14/2018, 3:40 PMcoder82
06/14/2018, 8:14 PMSlackbot
06/14/2018, 10:59 PMAyden
06/15/2018, 4:26 AM