Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Kotlin test DSL
//Lambda without receiver
fun buildString (
builderAction: (StringBuilder) -> Unit
) : String {
val stringBuilder = StringBuilder()
builderAction(stringBuilder)
return stringBuilder.toString()
}
val string = buildString {
it.append("Hello, ") // Note the need for adding 'it' in front
it.append("World!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment