From 62d92e3a19e2e6b599a8499dee24f857b46123b4 Mon Sep 17 00:00:00 2001 From: Bruce Richardson Date: Thu, 20 Sep 2018 15:17:40 +0100 Subject: syntax guide: move logical ops section beside if statement [skip ci] The "if" statement only covers a small set of the possible ways in which conditionals can be written, since it leaves the use of "and", "or" and "not" to the "Logical Operations" section. However, this is likely to be of interest to those reading about "if" statments, so move the "logical operations" section up to immediately follow it. This change also puts in the use of the "!=" operator in the example to widen the variety of combinations shown. --- docs/markdown/Syntax.md | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/docs/markdown/Syntax.md b/docs/markdown/Syntax.md index efb12e4..ff4c142 100644 --- a/docs/markdown/Syntax.md +++ b/docs/markdown/Syntax.md @@ -354,11 +354,34 @@ else endif opt = get_option('someoption') -if opt == 'foo' +if opt != 'foo' do_something() endif ``` +Logical operations +-- + +Meson has the standard range of logical operations which can be used in +`if` statements. + +```meson +if a and b + # do something +endif +if c or d + # do something +endif +if not e + # do something +endif +if not (f or g) + # do something +endif +``` + +Logical operations work only on boolean values. + ## Foreach statements To do an operation on all elements of an iterable, use the `foreach` @@ -409,28 +432,6 @@ foreach name, sources : components endforeach ``` -Logical operations --- - -Meson has the standard range of logical operations. - -```meson -if a and b - # do something -endif -if c or d - # do something -endif -if not e - # do something -endif -if not (f or g) - # do something -endif -``` - -Logical operations work only on boolean values. - Comments -- -- cgit v1.1