http://qs321.pair.com?node_id=824071


in reply to Re: in search of a more elegant if then else
in thread in search of a more elegant if then else

If it "fits," and is easy to read, use the ternary. Otherwise, use the if-then. Think in terms of which one will be easier to understand when someone else - ie. your boss - will be looking over your shoulder while you try to figure out a bug in something you wrote $x months or years ago.

Be kind to yourself.
  • Comment on Re^2: in search of a more elegant if then else

Replies are listed 'Best First'.
Re^3: in search of a more elegant if then else
by zebedee (Pilgrim) on Feb 19, 2010 at 09:07 UTC
    I go for the Friday 4 p.m. test. It's broken, it's 4 p.m. on Friday, you've had a LOOONGGG week, and you want to think about going home.

    Which one is going to be easier to read and fix?