We already discussed how, if a function's last parameter is a lambda, it can't be passed outside the parenthesis and inside curly braces, as if the lambda itself is the body of a control structure.
We covered this unless function in Chapter 2, Getting Started with Functional Programming, in the section, First-class and high-order functions. Let's have a look at the following code:
fun unless(condition: Boolean, block: () -> Unit) { if (!condition) block()}unless(someBoolean) { println("You can't access this website")}
Now, what happens if we combine vararg and lambda? Let's check it in the following code snippet:
fun <T, R> transform(vararg ts: T, f: (T) -> R): List<R> = ts.map(f)
Lambdas can be at the end of a function with a vararg ...