|
|
|
|
|
by chrisdotcode
4188 days ago
|
|
This: images <- get "http://example.com/images.json"
is objectively easier to reason about than: var images;
get("http://example.com/images.json", (err, resp) =>
if err throw err;
images = resp;
even though the former might be internally implemented as the latter.In addition, the former doesn't give the programmer the 'opportunity' to cause a race-condition, and encapsulates the failure entirely for you (automatically and defaultly); If `images` ends up erroring, and you use it again, then it'll short-circuit without crash, very similar to `then()`. |
|
I can make my code arbitrarily short if it doesn't have to be correct.