mbonnin
09/28/2017, 12:14 PMval action = Action<String> { println(it) }
bamboo
09/28/2017, 12:16 PMAction<T>
is treated specially in build scripts and in projects using the kotlin-dsl
pluginfun execute(target: T): Unit
would be treated as (T) -> Unit
, Action<T>
is treated as T.() -> Unit
mbonnin
09/28/2017, 12:18 PMbamboo
09/28/2017, 12:21 PMit.
qualifier is not needed when interacting with Action<T>
based Gradle APIs, for instance, `Project.copy(Action<CopySpec>)`:
copy {
from(“source”) // no `it.from`
into(“target”)
}
mbonnin
09/28/2017, 12:22 PMbamboo
09/28/2017, 12:22 PMval action: Action<String> = Action { println(this) }
action.execute("fooBar!")
mbonnin
09/28/2017, 12:23 PMit
works finebamboo
09/28/2017, 12:24 PM