Odd ternary operator results

topic posted Mon, September 25, 2006 - 11:41 AM by  Alex
Share/Save/Bookmark
Advertisement
OK, so I wrote this little script to test an issue I'd been having. Anyone know why the first block prints False, but the second block prints True?


#!/usr/bin/perl -wl

# Ternary Operator
1 == 1 ? $i = "True" : $i = "False";
print $i;

# Traditional if-then
if (1 == 1) {
$i = "True";
} else {
$i = "False";
}
print $i;
posted by:
Alex
SF Bay Area
Advertisement
Advertisement