Is there any case where this could be valid? (havi...
# announcements
i
Is there any case where this could be valid? (having
val
, not
var
with nullable type and no custom getter). Do you think we need IDE warning here?
private val requestId: String? = null
d
Copy code
class Job(
    private val requestId: String? = null
)

Job(requestId = "abc123")
?
j
Copy code
class Hello(private val someParam: String) {
    val hello: String?

    init {
        hello = if (someParam.contains("something") someParam else null
    }
}
y
null can be used to denote certain states definitely, and there's nothing to say that it always needs to be changed. Besides, if you're doing fp, you usually try to avoid
var
s in general, and so a nullable val could be useful with a copy constructor