in reply to Re^2: nested tabular ternary
in thread nested tabular ternary

I can't make heads or tail of your "more readable" "table". Did you mistakenly used tabs?

Aligning ? and : provides the best results for me. Parens provide a visual scope:

$result = ($major_length == 4800 ? 18 : ($major_length == 8552 ? ($val == 4 ? 33 : ($val == 1 ? 18 : die "not handled") ) : die "not handled" ) );

And then there's Perlish:

; $result = ($major_length == 4800 ? 18 : ($major_length == 8552 ? ($val == + 4 ? 33 + : ($val == 1 ? 18 + : die "not handled") ) : die "not + handled" ) )

None of these are particularly readable &mdash or maintainable. if should be used here.

Replies are listed 'Best First'.
Re^4: nested tabular ternary
by McDarren (Abbot) on Apr 11, 2006 at 03:03 UTC
    I can't make heads or tail of your "more readable" "table". Did you mistakenly used tabs?
    No, I never use tabs (I have vim configured to convert them to spaces), and I have no idea what happened there. It looked fine in Firefox (my default browser) when I first previewed and created it, but after yours and diotalevi's comments, I opened an IE window and took a look, and... ewww, I see what you mean. Anyway, I re-pasted (changed nothing) and now it looks okay for me in IE. So hopefully it makes sense to everyone else now :)
      I use Firefox (1.5.0.1 on WinXP), and your update fixed it for me as well. It's more readable, but it's still a far cry from being clear. It's not obvious which : associates with which condition and which :.