Assuming i have a variable `token: EndTagToken?` i...
# getting-started
t
Assuming i have a variable
token: EndTagToken?
in a when expression i want to check the following: it should be
true
if the token is null OR if
token.Value
is equal to specific String At the moment i use the following construct; is there more concise and shorter way to solve this?
Copy code
otherCondition && token?.let{ it.Value == "b" } ?: true
s
Shorter isn't always better. Why not just write it the way you described it in your message?
Copy code
otherCondition && (token == null || token.Value == "b")
👍 2
d
That is better, but if token can’t be smart cast, it won’t work.