Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.50 KB | None | 0 0
  1. package ch11.ex3_3_InvokeConventionInDSLs
  2.  
  3. class DependencyHandler {
  4.     fun compile(coordinate: String) {
  5.         println("Added dependency on $coordinate")
  6.     }
  7.  
  8.     operator fun invoke(
  9.             body: DependencyHandler.() -> Unit) {
  10.         body()
  11.     }
  12. }
  13.  
  14. fun main(args: Array<String>) {
  15.     val dependencies = DependencyHandler()
  16.     dependencies.compile("org.jetbrains.kotlin:kotlin-stdlib:1.0.0")
  17.     dependencies {
  18.         compile("org.jetbrains.kotlin:kotlin-reflect:1.0.0")
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement