Calling closures on objects
This commit is contained in:
@@ -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...
|
||||
}
|
||||
@@ -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.{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user