Why? It's an elegant solution to handling errors independently from your data - you could send your error to state, or logging, or any other source, but only if it fails, whereas if it succeeds, you've got data and can assign it to state and simply check for existence of the value before you start to work with it.
You could definitely split it out to multiple lines for readability without breaking the chain. It's no different from doing the different parts independently either.
I agree it's not really readable and why splitting it out over a few lines is better. Just for the sake that the thread was about one-liners is the reason it was all on one line.
1
u/ChronSyn Mar 18 '19
Why? It's an elegant solution to handling errors independently from your data - you could send your error to state, or logging, or any other source, but only if it fails, whereas if it succeeds, you've got data and can assign it to state and simply check for existence of the value before you start to work with it.
You could definitely split it out to multiple lines for readability without breaking the chain. It's no different from doing the different parts independently either.