Supported SAM constructor calls without function literal.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import java.util.*
|
||||
|
||||
fun box(): String {
|
||||
val list = ArrayList(Arrays.asList(3, 2, 4, 8, 1, 5))
|
||||
val expected = ArrayList(Arrays.asList(8, 5, 4, 3, 2, 1))
|
||||
val comparatorFun: (Int, Int) -> Int = { a, b -> b - a }
|
||||
Collections.sort(list, Comparator(comparatorFun))
|
||||
return if (list == expected) "OK" else list.toString()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import java.io.*
|
||||
|
||||
fun box(): String {
|
||||
val f : (File?, String?) -> Boolean = { dir, name -> if (name == null) false else (name as java.lang.String).endsWith(".md") }
|
||||
val filter = FilenameFilter(f)
|
||||
val listFiles = File(".").listFiles(filter)!!
|
||||
if (listFiles.size != 1) return "Wrong size: $listFiles.size"
|
||||
val name = listFiles[0].getName()
|
||||
return if (name == "ReadMe.md") "OK" else "Wrong name: $name"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun box(): String {
|
||||
var result = "FAIL"
|
||||
val f = { result = "OK" }
|
||||
val r = Runnable(f)
|
||||
r.run()
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
var result = "FAIL"
|
||||
|
||||
fun getFun(): () -> Unit {
|
||||
return { result = "OK" }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val r = Runnable(getFun())
|
||||
r.run()
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user