Hello!
Image a function that has a default argument.
Is there a way to call this function with a certain argument if a condition is met, else use the default argument?
Here’s some code:
fun foo(arg: String = "Default value”) { … }
fun main() {
foo(
arg = if (...) "My value" else default() // I'm inventing here a default function (a possible new feature, which of course can also be made in other ways) which calls the function with its default argument!
)
}
Here, the default argument is quite straight forward, but in more complex scenarios, it may involve more computations, which I’d like not to repeat when calling the function using the else case above (and thus use this new feature I’m mentioning)!
Thank you for your attention and support! Kotlin is awesome