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

x80486

08/28/2017, 12:48 AM
Suppose I have something like:
class Client(host: String = "localhost", port: Int = 50551, enableTls: Boolean = false)
. Now I would like to call the
constructor
with a different
port
, like:
val client = HelloWorldClient(443)
. Is there anything like a "wildcard" or something I can use that fills up the missing parameter? Something like
val client = HelloWorldClient(_, 443)
...
a

agomez

08/28/2017, 12:49 AM
you can use named params like
Client(port = 443)
👏 3
x

x80486

08/28/2017, 12:51 AM
Damn! Didn't know about that one! Thanks!
a

agomez

08/28/2017, 12:53 AM
glad to help another kotliner
4 Views