https://kotlinlang.org logo
#announcements
Title
# announcements
d

Dalinar

06/27/2017, 11:15 AM
@maciekjanusz to tell you the truth I had no use for it until I started programming in Kotlin JS, there I came across a few situations where it could be useful - usually in an if else type scenario. if "success" call with all parameters, if failure call with null on a parameter... (because you can't really pass anything else to the parameter since the value is not available due to failure. Why useful for me in JS? because in JS I have a lot of callback type situations. My way of thinking is that functions have parameters, but function types also have parameters - so why not? but I imagine it's not required most of the time by most people.
m

maciekjanusz

06/27/2017, 11:16 AM
mishaxz: interesting, but a different
Maciej
🙂
🙃 2
d

Dalinar

06/27/2017, 11:18 AM
ah sorry, I didn't know more than 1 person had this name ) I can't even pronounce it really - if it's Polish then that's like everything else in the language for me)
m

mg6maciej

06/27/2017, 11:19 AM
It's easier to pronounce than "chrząszcz brzmi w trzcinie" or "stół z powyłamywanymi nogami" 😉
😆 1
d

Dalinar

06/27/2017, 11:20 AM
I had a taxi driver once who was telling me Polish tongue-twisters, I think they must be the hardest in the world
m

mg6maciej

06/27/2017, 11:20 AM
Anyway, I'd need to see some code to think about it more.
d

Dalinar

06/27/2017, 11:20 AM
don't worry about it, I was just curious.. like I said, I think few people have a use for it
@mg6maciej I pulled this from my code, just to illustrate what I meant
Copy code
typealias NullableMatchedSelector = Action<JQuery?>

    fun ready(whenReady: NullableMatchedSelector, notFound: Callback?=null) {
        if (performNavigation) {
            navigate?.invoke()
            Wait(selector!!, whenReady, notFound).wait()
        } else whenReady(null) // this is where default could help, i.e. whenReady()
    }
as you can see it's pretty trivial, the benefits I mean - saving one
null
word.. since I can't think of any other use cases for now - I suspect that people rarely would benefit from default parameters in function types
4 Views