Int#downto

This commit is contained in:
Pavel V. Talanov
2012-07-20 12:38:07 +04:00
parent ad94786555
commit 8eb0fb31ca
4 changed files with 21 additions and 1 deletions
+5 -1
View File
@@ -43,7 +43,11 @@ var kotlin = {set:function (receiver, key, value) {
};
Kotlin.intUpto = function (from, limit) {
return Kotlin.$new(Kotlin.NumberRange)(from, limit - from + 1);
return Kotlin.$new(Kotlin.NumberRange)(from, limit - from + 1, false);
};
Kotlin.intDownto = function (from, limit) {
return Kotlin.$new(Kotlin.NumberRange)(from, from - limit + 1, true);
};
Kotlin.modules = {};
@@ -0,0 +1,11 @@
package foo
import java.util.ArrayList
fun box() : Boolean {
var elems = ArrayList<Int>()
for (i in 4 downto 0) {
elems.add(i)
}
return elems[0] == 4 && elems[1] == 3 && elems[2] == 2 && elems[3] == 1 && elems[4] == 0
}