Fix deprecations in testData: js semantics.

This commit is contained in:
Ilya Gorbunov
2015-09-15 20:19:57 +03:00
parent 92e66b0d81
commit 0e3e33e5c1
46 changed files with 119 additions and 121 deletions
@@ -72,4 +72,4 @@ fun bottlesOfBeer(count: Int): String =
// From the std package
// This is an extension property, i.e. a property that is defined for the
// type Array<T>, but does not sit inside the class Array
fun <T> Array<T>.isEmpty() = size == 0
fun <T> Array<T>.isEmpty() = size() == 0
+6 -6
View File
@@ -133,15 +133,15 @@ fun makeField(s: String): Field {
val lines: List<String> = s.splitBy("\n")
val w = Collections.max<String>(lines.toList(), comparator<String> { o1, o2 ->
val l1: Int = o1.size
val l2 = o2.size
val l1: Int = o1.length()
val l2 = o2.length()
l1 - l2
})!!
val data = Array(lines.size) { Array(w.size) { false } }
val data = Array(lines.size()) { Array(w.length()) { false } }
// workaround
for (i in data.indices) {
data[i] = Array(w.size) { false }
data[i] = Array(w.length()) { false }
for (j in data[i].indices)
data[i][j] = false
}
@@ -153,7 +153,7 @@ fun makeField(s: String): Field {
}
}
return Field(w.size, lines.size) { i, j -> data[i][j] }
return Field(w.length(), lines.size()) { i, j -> data[i][j] }
}
// An excerpt from the Standard Library
@@ -163,4 +163,4 @@ fun <K, V> MutableMap<K, V>.set(k: K, v: V) {
put(k, v)
}
val <T> Array<T>.isEmpty: Boolean get() = size == 0
val <T> Array<T>.isEmpty: Boolean get() = size() == 0