Hi. I am new to Kotlin. Question, how to prevent runtime errors in this case?
We had code like this:
private fun buildClient(ten: String?) = BaseApiUrlBuilder(baseUrl, ten).build()
.let(defaultWebClientBuilder::baseUrl)
.build()
and BaseApiUrlBuilder looked like this
class BaseApiUrlBuilder(
private val url: String,
private val ten: String? = null,
) {
then BaseApiUrlBuilder was changed to:
class BaseApiUrlBuilder(
private val url: String,
private val ten: String? = null,
private val localPort: Long = 8080
) {
And we did not get a compiler error but later got a runtime error on the first block of code.
How can runtime errors like this be prevented? By using named arguments and having Detekt enforce named arguments? Other insights? Thanks.