In my Kotlin project I would like to assign a default value to a function passed as a parameter, something like:
fun myFun(book: String, isCool: (book: String) -> Boolean = _ -> true) {
if (isCool(book)) println("$book is cool!")
}
Is this possible?
CodePudding user response:
Yes it is possible
fun myFun(book: String, isCool: (book: String) -> Boolean = { _ -> true }) {
if (isCool(book)) println("$book is cool!")
}