justtrying
justtrying

Reputation: 33

how to write continue in this way of typing "if"

hey I want to type if statement with the way 2 but I need to put there a continue and it not working with any ideas ? way 1 to type if

if ( x+2 < 0) {
    y=x+2;
}
else {
    y=-(x+2);
}

way 2 to type if

y=(x+2 < 0) ? x+2 : -(x+2)

my question how to type continue in the second way something like this :

(x==1) ? continue : x+1 ;

but this not working for me.

Upvotes: 3

Views: 50

Answers (1)

Mureinik
Mureinik

Reputation: 312008

The ternary operator (?) just returns a value (conditionally). You can't use it to execute arbitrary blocks of code. In other words, if you need to conditionally call continue, you need to use an if structure, not a ternary.

Upvotes: 7

Related Questions