• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Advantage of Ternary operator ?

 
Saibabaa Pragada
Ranch Hand
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, When should we go for Ternary operator when compared to if-else if-else loop?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64204
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If-else isn't a "loop".

I use the ternary operator whne choosing between two values, and if-else when choosing between operations.

For example:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic