PLDB
Languages Features Calendar About Lists Add Language
GitHub icon

Assert Statements

Assert Statements

Assert Statements are a language feature.

Assert Statements can be built into the language or included in a standard library.

Languages with Assert Statements include Java, C

Example from Java:

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

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]; }

Article source

PLDB - Build the next great programming language 路 v2022 Docs Acknowledgements Email GitHub