Is it possible to write "return" function inside a conditional operator as shown below?
a>b? return a: return b;
No. If you try this it won't compile.
The ternary operator requires expressions but not code. You can, however, call a function because the function becomes an instance of its return type so you get the return value from the operator.
The ternary operator requires expressions but not code. You can, however, call a function because the function becomes an instance of its return type so you get the return value from the operator.
But most of the book defines terinary operator as
Condition ? expression 1: exression 2;
My doubt : Is return statement is a expression or not.
Comment