Made foreach work with nullable iterables

This commit is contained in:
Santeri Hiltunen
2013-03-12 15:24:51 +02:00
committed by Pavel V. Talanov
parent 475d02a80f
commit 55c00b08e7
3 changed files with 37 additions and 1 deletions
+14
View File
@@ -0,0 +1,14 @@
import java.util.*;
public class ForEach {
public void test() {
ArrayList<Object> xs = new ArrayList<Object>();
List<Object> ys = new LinkedList<Object>();
for (Object x : xs) {
ys.add(x);
}
for (Object y : ys) {
xs.add(y);
}
}
}
+15
View File
@@ -0,0 +1,15 @@
import java.util.*
public open class ForEach() {
public open fun test() : Unit {
var xs : ArrayList<Any?>? = ArrayList<Any?>()
var ys : MutableList<Any?>? = LinkedList<Any?>()
for (x : Any? in xs!!)
{
ys?.add(x)
}
for (y : Any? in ys!!)
{
xs?.add(y)
}
}
}