Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a question about assert

 
avseq anthoy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see Sun Certified programmer & developer for java 2 write this:
Do not use assert expressions that can cause side effects!
but I can't understand its meaning.
Can someone explain it more detail?

Thanks!

avseq
 
Chris Allen
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the intent is to not build logic based on the assert statement that would not be available when the compile is done turning off assertions. One example I can think of is to base some logic that wraps an assert statement in an if statement. Bottom line, the assert should be used for debugging purposes, not to control logic.
 
avseq anthoy
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replying.
I can understand now!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic