A function as default value for argument in function, the default value function has also argument, wonders of Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FunctionDefaultValue { | |
companion object { | |
@JvmStatic | |
fun main(args: Array<String>) { | |
val result = foo(2) | |
println(result) | |
} | |
fun foo(int: Int, boolean: Boolean = bar(int)): String { | |
return "$int $boolean" | |
} | |
fun bar(int: Int) = int % 2 == 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment