Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assert

 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the following code:



When I run the following code, it compiles but I get the AssertionError, as expected. However, "String" does not output, as the K&B book woud suggest. So, do I have it correct when I think that, in this example, if the assert expression results in true, then "String" and "well well" are both output, but if the expression results in false, then neither print out and I automatically get an Assertion Error?
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The way you have it set up, you end the assert statement with the semicolon, and the SOP line is just another line.

You need to have a : after the assert condition, but you can't have a void method after the :.

You can do this.

 
J Brewer
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou, thankyou. I did not even notice my syntax error. Everything is running as it should now.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic