Created
June 25, 2020 18:29
-
-
Save cutiko/4196886a9c151206b1d0d9b90a61ae8b to your computer and use it in GitHub Desktop.
A function as default value for argument in function, the default value function has also argument, wonders of Kotlin
This file contains hidden or 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