in reply to Re: Can this If/Else be condensed into a 1 liner with a trailing If?
in thread Can this If/Else be condensed into a 1 liner with a trailing If?
I personally love using the conditional operator. You just have to be careful with it. For example:
displays:#! /usr/local/bin/perl -w use strict; $a = 1; $b = 2; (1) ? $a = 3 : $b = 4; print "1) a = $a, b = $b\n"; (1) ? ($a = 3) : ($b = 4); print "2) a = $a, b = $b\n";
Which may or may not be what you expect.1) a = 4, b = 2 2) a = 3, b = 2
Good luck!
{NULE}
PS I'm having issues with Opera again, please forgive me if I screw this post up (again.) Time for a new web-browser *sigh*.
|
|---|