Fix take method from iterating one extra element (KT-32024)

This commit is contained in:
Abduqodiri Qurbonzoda
2019-08-11 23:57:27 +03:00
parent 01a613dca4
commit 63895483fd
4 changed files with 32 additions and 32 deletions
@@ -153,9 +153,9 @@ object Filtering : TemplateGroupBase() {
var count = 0
val list = ArrayList<T>(n)
for (item in this) {
if (count++ == n)
break
list.add(item)
if (++count == n)
break
}
return list.optimizeReadOnlyList()
"""
@@ -201,9 +201,9 @@ object Filtering : TemplateGroupBase() {
var count = 0
val list = ArrayList<T>(n)
for (item in this) {
if (count++ == n)
break
list.add(item)
if (++count == n)
break
}
return list
"""