I went looking through Raphael.js
\'s source code to find out how he converted RGB values to HSB. I found out the function he did it in and I was in the process
H = C == 0
? null
: V == r
? (g - b) / C
: V == g
? (b - r) / C + 2
: (r - g) / C + 4
I've seen Dan Abramov using this indentation placement pattern. While I don't like how the conditional operator ?
no longer visually follows the condition, I prefer this to something like @lolmaus's example in that the indentation will always be consistent regardless the size of the conditional.
You actually start to look at it as ?
true :
false which is visually intuitive here. And this way, I find the ternary is much easier to spot and differentiate from the surrounding code.