Calling closures on objects

This commit is contained in:
Andrey Breslav
2010-11-22 17:44:27 +03:00
parent 5794ab6120
commit 73b12271c0
3 changed files with 18 additions and 3 deletions
+3 -3
View File
@@ -33,11 +33,11 @@ class AntBuilder {
fun library(initializer : Library.{ => Library}) {
val lib = new Library()
initializer(lib)
lib.initializer()
return lib
}
fun classpath
fun classpath...
fun module
fun module...
}
+14
View File
@@ -0,0 +1,14 @@
[inline] fun with<T>(receiver : T, body : T.{=> ()}) = receiver.body()
fun example() {
with(java.lang.System.out) {
println("foo");
print("bar");
}
System.out.{
}
}