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
Big Chungus
05/06/2021, 3:52 PM
Yes, it'll stop on first non-null value in the chain
m
Matěj Bystřický
05/06/2021, 3:54 PM
great, thank you! :)) And is this considered a good practice or is there a better way?
n
Nir
05/06/2021, 3:56 PM
Pretty sure this is fine for something this short
Nir
05/06/2021, 3:56 PM
If you have ten ?: in a row.... then idk maybe at that point its' time to reconsider what's going on
b
Big Chungus
05/06/2021, 3:56 PM
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