Conveying that an Array is empty

I never like the saying “No news is good news”
Call me paranoid, but when I don’t get a response for something my mind starts wondering what happened during the communication path that prevented me from getting a response.

We do the same thing with arrays, we loop through them and if there is no output we just assume that the array was empty. But what happens if the array wasn’t empty and you fat fingered part of the loop preventing output?

In code I always do some kind of logic check looking for empty arrays first but that adds extra IF statements which means more code to maintain.

Handlebars does something really cool that addresses this nicely, the #each statement can have an else…

{{#each ["Loop through Array].[$outputs]}}
{{["Loop through Array].[$item]}}
Array was empty

I like this because it is nice and clean and I know exactly what happed even when nothing happens.