aboutsummaryrefslogtreecommitdiff
path: root/doc/docs/de
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/de')
-rw-r--r--doc/docs/de/doc/control-flow/conditionals.md58
-rw-r--r--doc/docs/de/doc/control-flow/goto.md106
2 files changed, 164 insertions, 0 deletions
diff --git a/doc/docs/de/doc/control-flow/conditionals.md b/doc/docs/de/doc/control-flow/conditionals.md
index 56663d1..0d2574d 100644
--- a/doc/docs/de/doc/control-flow/conditionals.md
+++ b/doc/docs/de/doc/control-flow/conditionals.md
@@ -143,3 +143,61 @@ if a in list
143``` 143```
144 144
145</YueDisplay> 145</YueDisplay>
146
147Der `in`-Operator kann auch mit Tabellen verwendet werden und unterstützt die Variante `not in` für Verneinungen:
148
149```yuescript
150has = "foo" in {"bar", "foo"}
151
152if a in {1, 2, 3}
153 print "a ist in der Tabelle"
154
155not_exist = item not in list
156
157check = -> value not in table
158```
159
160<YueDisplay>
161
162```yue
163has = "foo" in {"bar", "foo"}
164
165if a in {1, 2, 3}
166 print "a ist in der Tabelle"
167
168not_exist = item not in list
169
170check = -> value not in table
171```
172
173</YueDisplay>
174
175Eine Ein-Element-Liste oder Tabelle prüft auf Gleichheit mit diesem Element:
176
177```yuescript
178-- [1,] prüft, ob wert == 1
179c = a in [1,]
180
181-- {1} prüft auch, ob wert == 1
182c = a in {1}
183
184-- Ohne Komma ist [1] ein Indexzugriff (tb[1])
185with tb
186 c = a in [1]
187```
188
189<YueDisplay>
190
191```yue
192-- [1,] prüft, ob wert == 1
193c = a in [1,]
194
195-- {1} prüft auch, ob wert == 1
196c = a in {1}
197
198-- Ohne Komma ist [1] ein Indexzugriff (tb[1])
199with tb
200 c = a in [1]
201```
202
203</YueDisplay>
diff --git a/doc/docs/de/doc/control-flow/goto.md b/doc/docs/de/doc/control-flow/goto.md
new file mode 100644
index 0000000..0e2a415
--- /dev/null
+++ b/doc/docs/de/doc/control-flow/goto.md
@@ -0,0 +1,106 @@
1# Goto
2
3YueScript unterstützt die goto-Anweisung und die Label-Syntax zur Steuerung des Programmflusses, wobei die gleichen Regeln wie bei Luas goto-Anweisung gelten. **Hinweis:** Die goto-Anweisung erfordert Lua 5.2 oder höher. Beim Kompilieren zu Lua 5.1 führt die Verwendung der goto-Syntax zu einem Kompilierfehler.
4
5Ein Label wird mit doppelten Doppelpunkten definiert:
6
7```yuescript
8::start::
9::done::
10::mein_label::
11```
12
13<YueDisplay>
14
15```yue
16::start::
17::done::
18::mein_label::
19```
20
21</YueDisplay>
22
23Die goto-Anweisung springt zu einem angegebenen Label:
24
25```yuescript
26a = 0
27::start::
28a += 1
29goto done if a == 5
30goto start
31::done::
32print "a ist jetzt 5"
33```
34
35<YueDisplay>
36
37```yue
38a = 0
39::start::
40a += 1
41goto done if a == 5
42goto start
43::done::
44print "a ist jetzt 5"
45```
46
47</YueDisplay>
48
49Die goto-Anweisung ist nützlich, um aus tief verschachtelten Schleifen zu springen:
50
51```yuescript
52for z = 1, 10
53 for y = 1, 10 do for x = 1, 10
54 if x^2 + y^2 == z^2
55 print 'Pythagoreisches Tripel gefunden:', x, y, z
56 goto ok
57::ok::
58```
59
60<YueDisplay>
61
62```yue
63for z = 1, 10
64 for y = 1, 10 do for x = 1, 10
65 if x^2 + y^2 == z^2
66 print 'Pythagoreisches Tripel gefunden:', x, y, z
67 goto ok
68::ok::
69```
70
71</YueDisplay>
72
73Sie können auch Labels verwenden, um zu einer bestimmten Schleifenebene zu springen:
74
75```yuescript
76for z = 1, 10
77 for y = 1, 10
78 for x = 1, 10
79 if x^2 + y^2 == z^2
80 print 'Pythagoreisches Tripel gefunden:', x, y, z
81 print 'versuche nächstes z...'
82 goto zcontinue
83 ::zcontinue::
84```
85
86<YueDisplay>
87
88```yue
89for z = 1, 10
90 for y = 1, 10
91 for x = 1, 10
92 if x^2 + y^2 == z^2
93 print 'Pythagoreisches Tripel gefunden:', x, y, z
94 print 'versuche nächstes z...'
95 goto zcontinue
96 ::zcontinue::
97```
98
99</YueDisplay>
100
101## Hinweise
102
103- Labels müssen innerhalb ihres Geltungsbereichs eindeutig sein
104- goto kann zu Labels auf derselben oder äußeren Geltungsbereichsebenen springen
105- goto kann nicht in innere Geltungsbereiche springen (wie in Blöcke oder Schleifen)
106- Verwenden Sie goto sparsam, da es den Code schwieriger zu lesen und zu warten machen kann