sumedha rao wrote:thanks for your quick reply,how can i do the same thing without an else block
The same thing as what? It's hard to tell what you're trying to do in the original code - it seems unnecessarily complex, checking for things that could not possibly happen. What are you trying to achieve?
In particular, why would you write "if (x)" and then immediately check
again if x is true or not? And then in the else clause, check yet again to see if x is true or not? It seems like this whole thing could be written easily with EITHER (a) a single if/else, or (b) a single ternary operation. Not both. And not one if/else with TWO ternary operations. How many times do you need to
test if x is true or not?