From: Rico Tzschichholz Date: Mon, 23 Mar 2020 13:57:51 +0000 (+0100) Subject: manual: Update from wiki.gnome.org X-Git-Tag: 0.48.2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cca368f278707b9cf637082a65efca1742a33aa6;p=thirdparty%2Fvala.git manual: Update from wiki.gnome.org --- 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