asserte

Asserts that the given value is true, but unlike standard assert throws an exception on error.

  1. T asserte(T value, Throwable ex)
    T
    asserte
    (
    T
    )
    (,
    lazy Throwable ex
    )
  2. T asserte(T value, string msg)
  3. T asserte(T value, Dg dg)

Parameters

value T

The value to test.

ex Throwable

The exception to throw if the value evaluates to false.

Return Value

Type: T

value, if cast(bool)value is true. Otherwise, ex is thrown.

Examples

auto f = asserte(fopen("data.txt"));
auto line = readln(f);
asserte(line.length, new IOException); // expect a non-empty line

Meta