The ternary operator evaluates to an expression and expressions can't contain a return statement (how would that behave if you were to assign the expression to a variable?). However, you could very well return the result of a ternary operator, i.e. return condition? returnValue1 : returnValue2;
On your specific point, I don't see why you would like to return. It looks like you're trying to do something only if a condition is fulfilled. A simple if
statement would probably be more adequate there.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…