• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

assert with ternary operator

 
Ranch Hand
Posts: 34
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Source : http://www.etattva.com/

The explaination says :
Compilation error because Here ternary operator & augmented form of assertion are used in a wrong way. Syntex of ternary operator is <Boolean exp>?<msg>:<msg> In augmented form of assertion, syntax is, assert <Boolean expression> : <msg expression> If we write it as assert (a > 0) ? <Boolean exp> : <Boolean exp>; then it will compile .

I am not clear with the bold part.For eg if we use it as follows:
int a=0;
assert (a > 0) ? true : false;

what is the above code doing ??
 
Ranch Hand
Posts: 1032
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
assert (a > 0) ? true : false; is just a roundabout way of saying:
assert a>0;
 
reply
    Bookmark Topic Watch Topic
  • New Topic