hi, just wanted to ask a quick question regarding ...
# announcements
m
hi, just wanted to ask a quick question regarding multiple elvis operators. TLDR: is this correct?
Copy code
id = action.id ?: state.activeId ?: -1
b
Yes, it'll stop on first non-null value in the chain
m
great, thank you! :)) And is this considered a good practice or is there a better way?
n
Pretty sure this is fine for something this short
If you have ten ?: in a row.... then idk maybe at that point its' time to reconsider what's going on
b
Can't comment on good practices, but I'm using this everywhere where I need some default state. I also prefer returning null over throwing an exception, which ties in nicely with this pattern on consumer end