Remove "Iterator.iterator()" intrinsic, add stdlib function
This commit is contained in:
@@ -186,17 +186,7 @@ public final class MiscTest extends AbstractExpressionTest {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIterableExtension() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testIterationOverIterator() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
public void testStringInterpolationEvaluationOrder() throws Exception {
|
||||
fooBoxTest();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package foo
|
||||
|
||||
import java.util.*
|
||||
import java.lang.*
|
||||
|
||||
public inline fun <T, C: MutableCollection<in T>> Iterator<T>.takeWhileTo(result: C, predicate: (T) -> Boolean) : C {
|
||||
for (element in this) if (predicate(element)) result.add(element) else break
|
||||
return result
|
||||
}
|
||||
|
||||
fun box(): Any? {
|
||||
val c = ArrayList<Int>()
|
||||
for (i in 0..5) {
|
||||
c.add(i)
|
||||
}
|
||||
|
||||
val d = ArrayList<Int>()
|
||||
|
||||
c.iterator().takeWhileTo(d, {i -> i < 4 })
|
||||
return d.size() == 4
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package foo
|
||||
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun box(): Boolean {
|
||||
val c = ArrayList<Int>()
|
||||
for (i in 0..5) {
|
||||
c.add(i)
|
||||
}
|
||||
|
||||
var s = ""
|
||||
for (i in c.iterator()) {
|
||||
s = s + i.toString()
|
||||
}
|
||||
|
||||
return s == "012345"
|
||||
}
|
||||
Reference in New Issue
Block a user