Assert Statements is an actively used design pattern.

?Years Old
  • Assert Statements does not currently rank in our top 50% of entities I track
  • I have 10 facts about Assert Statements. what would you like to know? email me and let me know how I can help.
  • Read more about Assert Statements

Languages with Assert Statements include c, java

Example from c:

#include <assert.h>
int i, a[10];
for (i = 0; i < 10; ++i)
  {
  assert(0 <= i && i < 10);
  a[i] = 10-i;
  }
for (i = 0; i < 10; ++i)
  {
  assert(0 <= i && i < 10);
  assert(0 <= a[i] && a[i] < 10);
  a[a[i]] = a[i];
  }

Example from java:

// By default, assertions are disabled
// java –enableassertions Test
int score = 10;
assert score >= 10 : " Below";
System.out.println("score is "+score);

Last updated November 21st, 2019