Skip to content

Instantly share code, notes, and snippets.

@cutiko
Created June 25, 2020 18:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
A function as default value for argument in function, the default value function has also argument, wonders of Kotlin
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