Category talk:Wren-check: Difference between revisions

Content added Content deleted
(→‎Source code: Added a method to check if a string is a valid identifier.)
(→‎Source code: Added Check.ok method.)
Line 4: Line 4:


/*
/*
Check is a class containing static methods to check that a particular value is
Check is a class containing static methods to check that:
of a given type or types and, where possible, within a given range of values.
(1) a particular value is of a given type or types and, where possible, within
a given range of values; or
(2) a more general condition is met.
If it isn't, the fiber is aborted with an appropriate error message.
If it isn't, the fiber is aborted with an appropriate error message.
*/
*/
Line 284: Line 286:
}
}
}
}

/* Methods to check if a condition is met. */
static ok(condition, message) {
if (!condition) Fiber.abort(message)
}

static ok(condition) { ok(condition, "Condition is not met.") }
}</lang>
}</lang>