+ 2
Hey can anyone tell me why the return statement is giving me void return type??
Syntax exp1?exp2:exp3 why exp2 and exp3 return void when we use return statement ???đ https://code.sololearn.com/c5wps868h6Hy/?ref=app
1 Answer
+ 4
Expressions are two or more operands connected by an operator, while the "return" is a statement. Expressions should not contain return statements. Why do you want to return anyway? The ternary operator evaluates the condition and "returns" it. So you don't need to use the return statement there. The following thread might help you
https://stackoverflow.com/questions/35231609/why-cant-we-have-return-in-the-ternary-operator