if ($a==1) {
print "A is 1!";
} else {
print "A is not 1!";
}
Cool, huh?
public class !CondOpTest {
public static void main(String[] args) {
new !CondOpTest(new Integer(args[0));
}
public !CondOpTest(Integer a) {
if (a.intValue()==1) {
System.out.println("A is 1!");
} else {
System.out.println("A is not 1!");
}
}
}
public class !CondOpTest {
public static void main(String[] args) {
new !CondOpTest(new Integer(args[0));
}
public !CondOpTest(Integer a) {
System.out.println((a.intValue()==1 ) ? "A is 1!" : "A is not 1!");
}
}
In Perl, however, things are slightly different.
The above also works in C
int a = 0; (a == 1) ? printf("A is 1!\n") : printf("A is not 1!\n");
No page links to TernaryOperator.