I'm looking to convert some code from JavaScript to C#, but I'm having trouble grasping a certain section...
function getHisto(pixels) {
var histosize = 1 << (3 * sigbits),
histo = new Array(histosize),
index, rval, gval, bval;
pixels.forEach(function(pixel) {
rval = pixel[0] >> rshift;
gval = pixel[1] >> rshift;
bval = pixel[2] >> rshift;
index = getColorIndex(rval, gval, bval);
histo[index] = (histo[index] || 0) + 1;
});
return histo;
}
What is the expected output of histo[]? I'm confused by this line:
histo[index] = (histo[index] || 0) + 1;
If more information is needed, please let me know.
Edit 1: Specifically referring to histo[index] || 0