7
Aşağıdaki kod var: Böyle ararsamKotlin: For döngüsü bir yineleyici yönteme sahip olmalı - bu bir hata mı?
public fun findSomeLikeThis(): ArrayList<T>? {
val result = Db4o.objectContainer()!!.queryByExample<T>(this as T) as Collection<T>
if (result == null) return null
return ArrayList(result)
}
:
For-loop range must have an 'iterator()' method
Burada bir şey eksik:
var list : ArrayList<Person>? = p1.findSomeLikeThis()
for (p2 in list) {
p2.delete()
p2.commit()
}
Bana hatayı verecek?
listelemek dönebilirsiniz .forEach {it.delete() ...} –
'list? .forEach {...}' null (yukarıda belirtildiği gibi, sadece kod bloğunu ekleyerek) –