Lambda with Receiver

  • lambda that is invoked on an subject
  • like 'apply'

fun builder() : String { 
  return StringBuilder().append("content").build()
}


fun stringDsl(receiver: StringBuilder.() -> Unit) : String { 
  StringBuilder().apply(receiver).build()
}


fun dsl() : String = stringDsl { 
  append("content")
}


Back Home Next