https://kotlinlang.org logo
Title
t

tipsy

06/23/2017, 5:19 PM
what's a better way of writing this?:
class EmbeddedJettyFactory(jettyServer: () -> Server) : EmbeddedServerFactory {
    private var server = Server(QueuedThreadPool(200, 8, 60000))
    init {
        this.server = jettyServer.invoke()
    }
}
d

diesieben07

06/23/2017, 5:25 PM
tipsy:
class EmbeddedJettyFactory(jettyServer: () -> Server = { Server(QueuedThreadPool(200, 8, 60000)) }) : EmbeddedServerFactory {
    private val server = jettyServer()
}
t

tipsy

06/23/2017, 5:26 PM
thanks, it's a pretty beefy class declaration, but it's a nicer i guess
think i'll go for it
d

diesieben07

06/23/2017, 5:26 PM
You can turn the lambda into a method and use a method reference if you prefer that.
t

tipsy

06/23/2017, 5:28 PM
no, i think i like it, just takes some getting used to
actually, i extracted it
thanks
👍 1