:one: ``` open class BaseResponse { val isSucc...
# random
a
1️⃣
Copy code
open class BaseResponse {
    val isSuccess: Boolean
        get() = errorCode == 0
}
2️⃣
Copy code
open class BaseResponse {    
    fun isSuccess() = errorCode == 0
}
1️⃣ 5
n
If simple data processing is being done then go for a property otherwise use a function. In this case the property can be a one liner ( https://kotlinlang.org/docs/reference/coding-conventions.html#property-formatting ).
👍 1
a
If
errorCode
is a
val
, you can use
val isSuccess = errorCode == 0
a
@Andreas Sinz but when we change the errorCode, the property won’t be recalculated in your example
t
@ahegazy, that's why it's important for
errorCode
to be
val
for that to work.
val
can't change.
a
yeah missed that part. I guess my case is different then 🙂