Hi. I am new to Kotlin. Question, how to prevent...
# codingconventions
t
Hi. I am new to Kotlin. Question, how to prevent runtime errors in this case? We had code like this:
Copy code
private fun buildClient(ten: String?) = BaseApiUrlBuilder(baseUrl, ten).build()
        .let(defaultWebClientBuilder::baseUrl)
        .build()
and BaseApiUrlBuilder looked like this
Copy code
class BaseApiUrlBuilder(
    private val url: String,
    private val ten: String? = null,
) {
then BaseApiUrlBuilder was changed to:
Copy code
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.
e
this should not result in a runtime error, unless the second change was in a separate artifact and the first was not recompiled
if they are in separate artifacts, then you need to be aware of ABI compatibility. adding parameters, default or not, is not ABI compatible.
j
@Tara Czutno what runtime error did you get? Was it
NoSuchMethodError
?