From cca368f278707b9cf637082a65efca1742a33aa6 Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Mon, 23 Mar 2020 14:57:51 +0100 Subject: manual: Update from wiki.gnome.org --- doc/manual/manual.xml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'doc') diff --git a/doc/manual/manual.xml b/doc/manual/manual.xml index d551a428b..3eeb9d0cc 100644 --- a/doc/manual/manual.xml +++ b/doc/manual/manual.xml @@ -1085,14 +1085,25 @@
Contract programming -TODO: requires, ensures. -requires ( ... ) Denotes things that must be true to start execution. -ensures ( ... ) Denotes things that must be true to end execution. -
- -
-Examples -TODO: write examples. +Vala supports basic contract programming features. A method may have preconditions (requires) and postconditions (ensures) that must be fulfilled at the beginning or the end of a method respectively: + 0 && ]]> += 0.0 && ]]> += 0.0 && ]]> + + + +result is a special variable representing the return value. +For example, if you call method_name with arguments 5 and 3.0, it will output a CRITICAL message and return 0. + + + +Output: = 0.0 && d <= 1.0' failed +0]]> +Vala allows you to manage the safety of issued messages at 6 levels: ERROR, CRITICAL, INFO, DEBUG, WARNING, MESSAGE. For example, the following code will cause a runtime error. + +
Back to Vala Reference Manual -- cgit v1.2.1